Syntax errors or invalid `$ref` pointers in your OpenAPI specification break client SDK builds, doc generators, and API Gateway routing rules. Implementing automated validation in your continuous integration pipeline prevents invalid specs from entering production.
1. Common Validation Check Categories
- Structural Syntax: Verifying valid YAML/JSON formatting and required OAS root properties (openapi, info, paths).
- Reference Resolution: Ensuring all $ref JSON pointers resolve to existing components or external URI schemas.
- Schema Integrity: Confirming type definitions comply with JSON Schema keywords.
- Semantic Rules: Enforcing operationId uniqueness, valid HTTP response status code formats ('200', '404'), and path parameter matching.
2. Integrating Spec Validation into GitHub Actions
name: Validate OpenAPI Specification
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run APIForge CLI Validation
run: |
npx @apiforge/cli validate ./openapi.yaml --strictInstant Online OpenAPI Validation
Paste your OpenAPI URL or content into APIForge for instant syntax parsing, reference checking, and zero-hallucination analysis.
