OpenAPI Validator.

Paste an API spec and press Validate. A document with an openapi field is checked against the OpenAPI 3.0 schema; one with swagger: "2.0" against the Swagger 2.0 schema.

What it checks

The structure of the spec, field by field

The validator checks the document against the official JSON schema for OpenAPI 3.0, published by the OpenAPI Initiative. Errors give the JSON path of the field and the line. In paths, ~1 stands for /, so /paths/~1pets is the /pets path.

  • Required fields: info.title, info.version, responses on every operation, description on every response, url on every server, and content in a request body.
  • Types and allowed values: a number where the spec expects a string, schema types other than the six JSON types, parameter locations other than path, query, header and cookie.
  • Unknown fields: a typo like summery:, a path that does not start with /, a response code such as ok or 600.
  • Swagger 2.0: this page checks against OpenAPI 3.0, so a Swagger file gets an error with a Switch and validate link to the Swagger 2.0 schema. There, components in a Swagger file is reported as / unknown property 'components'.

YAML syntax is checked first, and the validator also warns about values that YAML reads as something else, such as a version 1.0 that becomes the number 1. Everything runs in your browser; specs are never uploaded.

Common mistakes

What the validator catches, with the message you get

An unquoted version number

info:
  title: Pet Store
  version: 1.0

Message: /info/version must be string. YAML reads 1.0 as the number 1, and the spec requires a string. Quote it: version: "1.0". The same goes for openapi: 3.0, which gives /openapi must be string.

A response without a description

responses:
  '200':
    content:
      application/json:
        schema:
          type: object

Message: /paths/~1pets/get/responses/200 missing required property 'description'; /paths/~1pets/get/responses/200 missing required property '$ref'. A response is either an object with a description or a $ref, so you get one line for each. Add a description, even a short one.

A path parameter without required: true

/pets/{petId}:
  get:
    parameters:
      - name: petId
        in: path
        schema:
          type: string

Message: /paths/~1pets~1{petId}/get/parameters/0/in must be one of: query, then the same for header and cookie. A path parameter must have required: true; without it, the parameter is valid only in the other locations, which is what the message lists.

A typo in a field name

/pets/{petId}:
  get:
    summery: Get a pet

Message: /paths/~1pets~1{petId}/get unknown property 'summery'. Only the fields the spec defines are allowed, plus your own extensions, which start with x-, such as x-internal: true.

required: true on a property

Pet:
  type: object
  properties:
    name:
      type: string
      required: true

Message: /components/schemas/Pet/properties/name/required must be array. In a schema, required is a list of property names on the object: required: [name] next to properties.

A type name from another language

schema:
  type: int

Message: /paths/~1pets~1{petId}/get/parameters/0/schema/type must be one of: array, boolean, integer, number, object, string. Use type: integer, with format: int32 or int64 for the size.

Swagger 2.0 fields in an OpenAPI 3.0 file

openapi: 3.0.3
definitions:
  Pet:
    type: object

Message: / unknown property 'definitions'. In OpenAPI 3.0, schemas live under components.schemas, and references change to #/components/schemas/Pet.

A path without the leading slash

paths:
  pets/{petId}:
    get:

Message: /paths unknown property 'pets/{petId}'. Every key under paths must start with /; it is appended to the server URL.

Limits

What a schema check cannot tell you

  • OpenAPI 3.1 is not supported: openapi: 3.1.0 is reported as /openapi has invalid format, because the schema accepts only 3.0.x versions.
  • References are not resolved: a $ref to #/components/schemas/Pet passes even when there is no such schema.
  • Rules between fields: a path parameter whose name does not match the {placeholder} in the path, the same operationId on two operations, a security requirement that names an undefined scheme, and an example that does not match its schema all pass.
  • Swagger 2.0 path parameters without required: true are not reported.

For those checks, use a linter that reads the whole document, such as Redocly CLI or Spectral.

Validate specs from the browser toolbar with the Chrome extension