ProductCompareToolsPricingBlog
Sign inCreate an account

Tutorials

OpenAPI Spec Validation: Common Errors and How to Fix Them

Every OpenAPI validation error has a pattern. Here are the 10 errors you will hit most often, why they happen, and the exact fix, with copy-paste YAML.

Morgan Kotter · Updated March 30, 2026

OpenAPI validation errors block documentation generation, break code generators, and prevent CI pipelines from passing. The error messages are often cryptic. A single misplaced property can cascade into dozens of downstream failures.

This guide covers the 10 most common validation errors across OpenAPI 3.0 and 3.1 specs, ordered by frequency. Each error includes the exact error message you will see, why it happens, and a before/after YAML fix. If you are chasing one specific message from Spectral, swagger-cli, kin-openapi, or openapi-generator, the OpenAPI error reference has a dedicated page per error with a minimal reproduction.

1. Broken $ref Path

Error: Can't resolve $ref: #/components/schemas/user

The most common OpenAPI error. A $ref points to a schema that does not exist, usually because of a case mismatch or typo.

Broken (case mismatch)

# The $ref says "user" but the schema is "User"
requestBody:
  content:
    application/json:
      schema:
        $ref: '#/components/schemas/user'  # lowercase

components:
  schemas:
    User:  # uppercase
      type: object

Fixed

requestBody:
  content:
    application/json:
      schema:
        $ref: '#/components/schemas/User'  # matches exactly

components:
  schemas:
    User:
      type: object

Fix: $ref values are case-sensitive. Search your spec for every $ref and verify the target exists with the exact same casing.

2. Missing responses Object

Error: Operation must have at least one response defined

Every operation (get, post, etc.) requires a responses object. This is easy to forget on draft endpoints.

Missing responses

paths:
  /health:
    get:
      summary: Health check
      # No responses defined

Fixed

paths:
  /health:
    get:
      summary: Health check
      responses:
        '200':
          description: Service is healthy

3. Invalid type Value

Error: Schema type must be one of: string, number, integer, boolean, array, object

OpenAPI 3.0 only allows six types. Common mistakes: using float (use number with format: float), date (use string with format: date), or null (use nullable: true in 3.0, or type: ['string', 'null'] in 3.1).

Invalid types

# These are NOT valid OpenAPI types
properties:
  price:
    type: float      # not a valid type
  birthday:
    type: date       # not a valid type
  deleted_at:
    type: null        # not valid in 3.0

Fixed

properties:
  price:
    type: number
    format: float
  birthday:
    type: string
    format: date
  deleted_at:
    type: string
    format: date-time
    nullable: true    # OpenAPI 3.0
    # For 3.1: type: ['string', 'null']

4. Example/Default Type Mismatch

Error: Example value "100" is not valid for schema type integer

YAML treats unquoted numbers as integers and quoted values as strings. If your schema says type: integer but your example is "100"(a string), validation fails.

Mismatched example types

properties:
  port:
    type: integer
    example: "8080"   # string, not integer
  enabled:
    type: boolean
    example: "true"   # string, not boolean

Fixed

properties:
  port:
    type: integer
    example: 8080     # unquoted = integer
  enabled:
    type: boolean
    example: true     # unquoted = boolean

5. Duplicate operationId

Error: operationId "getUser" is already used by another operation

Every operationId must be unique across the entire spec. This commonly happens when copy-pasting endpoint definitions.

Fix: Use a consistent naming convention like verb + Resource: listUsers, getUser, createUser, updateUser, deleteUser.

6. Missing or Invalid info Object

Error: Info object must have a title and version

The info object at the root of every spec requires title and version. Both must be strings. A common mistake: using a number for version.

Invalid info

openapi: 3.0.3
info:
  title: My API
  version: 1.0    # number, not string

Fixed

openapi: 3.0.3
info:
  title: My API
  version: "1.0"  # string

Specway reads your spec on import and builds the reference from it, so fixing these errors first means fewer surprises in the published docs. Import your spec.

7. Path Parameter Not Declared

Error: Path parameter "id" must be defined in the parameters section

If your path contains {id}, there must be a matching parameter definition with in: path and required: true.

Missing path parameter definition

paths:
  /users/{id}:        # {id} in path
    get:
      summary: Get user
      responses:
        '200':
          description: OK
      # No parameters defined for {id}

Fixed

paths:
  /users/{id}:
    get:
      summary: Get user
      parameters:
        - name: id
          in: path
          required: true    # path params MUST be required
          schema:
            type: string
      responses:
        '200':
          description: OK

8. Required Field Not in Properties

Error: Required property "email" is not defined in properties

Every item in the required array must match a key in properties. Typos in either location cause this error.

Mismatched required field

schemas:
  User:
    type: object
    required:
      - email          # listed as required
    properties:
      email_address:   # but the property is named differently
        type: string

Fixed

schemas:
  User:
    type: object
    required:
      - email_address  # matches the property name
    properties:
      email_address:
        type: string

9. Invalid HTTP Status Code

Error: Response status code must be a string "200", not integer 200

In OpenAPI, HTTP status codes under responses must be strings (quoted). YAML interprets unquoted 200 as an integer.

Integer status codes

responses:
  200:              # YAML sees this as integer
    description: OK
  404:
    description: Not found

Fixed

responses:
  '200':            # quoted string
    description: OK
  '404':
    description: Not found

10. Array Without items

Error: Schema of type array must have an items property

Every type: array schema requires an items definition. Without it, tools cannot generate types or validate responses.

Array without items

properties:
  tags:
    type: array
    # Missing items definition

Fixed

properties:
  tags:
    type: array
    items:
      type: string

Validation Tools

Run validation before every commit. Here are the main options:

# Spectral (most popular, customizable rules)
npx @stoplight/spectral-cli lint openapi.yaml

# Redocly CLI
npx @redocly/cli lint openapi.yaml

# swagger-cli (basic validation)
npx swagger-cli validate openapi.yaml

# Online: paste your spec at editor.swagger.io

Add linting to CI so invalid specs never reach production:

# .github/workflows/lint-spec.yml
name: Lint OpenAPI
on: [pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx @stoplight/spectral-cli lint openapi.yaml

Questions

What is the best tool to validate an OpenAPI spec?+

Spectral by Stoplight is the most widely used OpenAPI linter. Run it locally with `npx @stoplight/spectral-cli lint openapi.yaml` or integrate it into CI. For online validation, editor.swagger.io and Redocly both offer browser-based validators.

What is the difference between OpenAPI 3.0 and 3.1 validation?+

OpenAPI 3.1 aligns with JSON Schema 2020-12, introducing nullable via type arrays (type: [string, "null"]) instead of the nullable: true keyword from 3.0. It also supports $id, $anchor, and if/then/else in schemas. Many validation errors occur when mixing 3.0 and 3.1 syntax.

Why does my valid YAML fail OpenAPI validation?+

Valid YAML is not necessarily valid OpenAPI. The YAML syntax may be correct but the structure may violate OpenAPI rules (missing responses, invalid $ref paths, wrong property nesting). Use an OpenAPI-specific validator, not just a YAML parser.

Read next

  • OpenAPI error referenceA page per error message from Spectral, swagger-cli, kin-openapi and openapi-generator.
  • OpenAPI 3.1 vs 3.0: what changed
  • How to generate API documentation with AI

See your docs in a minute

Paste the link to your OpenAPI file. Free for one API, no card needed.

Get startedSee pricing

API reference docs from your OpenAPI file.

Product

  • How it works
  • Endpoint pages
  • Code samples
  • Spec sync
  • Spec changes
  • API versions
  • Changelog
  • Recipes
  • Docs assistant
  • Your domain and look
  • Insights
  • Private docs
  • Team SSO
  • Pricing

Compare

  • vs ReadMe
  • vs Mintlify
  • vs Redocly
  • vs Scalar
  • vs Swagger UI
  • vs Postman
  • All comparisons

Tools

  • OpenAPI validator
  • OpenAPI diff
  • Swagger 2 to OpenAPI 3
  • cURL to code
  • JWT decoder
  • YAML and JSON
  • All tools

Resources

  • Guides
  • OpenAPI errors
  • Glossary
  • Public API specs
  • Blog
  • Help

Company

  • About
  • Contact
  • Privacy
  • Terms

© 2026 Specway. Made in Utah by Modlific LLC.

GitHubXLinkedIn