Skip to content

OpenAPI Validator

Paste an OpenAPI 3.0, 3.1 or Swagger 2.0 spec in YAML or JSON. It finds broken $refs, undeclared path parameters, duplicate operationIds, missing responses and other mistakes that break code generators and docs.

Spec (YAML or JSON)
Report

Last reviewed:

What is OpenAPI?

The OpenAPI Specification is a standard, language-neutral format for describing HTTP APIs: their paths, operations, parameters, request bodies, responses, authentication and data models. It started as Swagger, whose 2.0 version is still widely used, and was renamed OpenAPI when it moved to the Linux Foundation in 2016. OpenAPI 3.0 reorganised the format around components and requestBody, and 3.1 (2021) aligned schemas fully with JSON Schema and added webhooks. A spec is a single YAML or JSON document, often called openapi.yaml.

From that one file, tools generate interactive documentation (Swagger UI, Redoc), client SDKs and server stubs in many languages, mock servers, contract tests and API gateway configuration. That makes mistakes expensive: a broken $ref can crash a code generator, a path parameter that is not declared generates a client method missing an argument, and two operations sharing an operationId produce colliding function names.

Many of these mistakes are invisible when you read the YAML, because the file is long and full of cross-references. A validator walks the whole document and checks structure and consistency, so you find problems before your build pipeline or API consumers do.

How to use this tool

  1. Paste your spec into the left box, click Open file… to load a .yaml, .yml or .json file, or click Paste. Sample loads a small Orders API with several deliberate mistakes.
  2. The spec is parsed and checked as you type. If the YAML or JSON itself is invalid, the status line shows the line and column of the syntax error.
  3. Read the summary: API title, detected version (OpenAPI 3.0, 3.1 or Swagger 2.0), and counts of paths, operations, schemas and problems.
  4. Read the Report. Each issue is marked Error or Warning, with a plain-language message and the location in the document, such as paths./orders/{orderId}.get.parameters[0].
  5. Untick Show warnings to focus on errors. Warnings cover things that are allowed but usually unintended, such as unused schemas or external references that were not checked.

Examples

What the sample spec reports

The sample contains this operation:

  /orders/{orderId}:
    get:
      operationId: getOrder
      parameters:
        - name: id
          in: path
          schema: { type: string }
      responses:
        "200":
          description: One order
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Ordr" }
        "404": {}

The report includes:

Error  $ref "#/components/schemas/Ordr" points to nothing.
Error  Each response needs a description.                         (…get.responses.404)
Error  Path parameter "id" must have required: true.
Error  Path parameter "id" is not in the path /orders/{orderId}.
Error  {orderId} is in the path but no path parameter named "orderId" is defined.

The fix is to rename the parameter to orderId, add required: true, correct the typo to Order, and give the 404 response a description. The rest of the sample produces a duplicate operationId error, an undefined security scheme apiKey, info.version must be a string for version: 1.0, and a warning that the Customer schema is never used: 9 errors and 1 warning in total.

A Swagger 2.0 parameter without a type

swagger: "2.0"
info: { title: Pets, version: "1.0" }
paths:
  /pets/{petId}:
    get:
      parameters:
        - name: petId
          in: path
          required: true
      responses:
        200:
          description: A pet
          schema: { $ref: "#/definitions/Pet" }
definitions:
  Pet: { type: object }

Result: one error, Parameter "petId" needs a type. In Swagger 2.0, non-body parameters declare type directly (for example type: string), whereas OpenAPI 3 uses a schema.

Common errors and how to fix them

  • info.version must be a string. version: 1.0 is read by YAML as the number 1, losing the .0. Quote it: version: "1.0". The same applies to openapi: 3.0 written without a patch number; use openapi: 3.0.3 or 3.1.0.
  • $ref … points to nothing. A typo in the schema name, or a wrong path. In OpenAPI 3 schemas live under #/components/schemas/; in Swagger 2.0 under #/definitions/.
  • Path parameter mismatches. Every {name} in a path needs a parameter with in: path, the same name and required: true. Names are case-sensitive.
  • Duplicate operationId. Usually from copying an operation. Every operation needs a unique ID because generators use it as the method name.
  • Security scheme not defined. An operation's security names a scheme that is missing from components.securitySchemes (or securityDefinitions in 2.0). Define it, or fix the spelling.
  • "GET" is not a valid key here. HTTP methods in a path item must be lowercase: get, post and so on.
  • Paths must start with "/". Write /users/{id}, not users/{id}. The server base URL belongs in servers.
  • YAML syntax errors such as "bad indentation of a mapping entry". Fix the indentation at the reported line; the YAML formatter can help.

When developers use this

  • Checking a hand-edited spec before committing it, so documentation and SDK builds do not fail in CI.
  • Reviewing a spec received from another team or vendor before generating a client from it.
  • Debugging a code generator or Swagger UI error that only says "could not resolve reference".
  • Migrating a Swagger 2.0 document to OpenAPI 3 and checking that nothing was lost.
  • Cleaning up unused schemas left behind after endpoints were removed.

Privacy and how it works

The spec is parsed with js-yaml (which also reads JSON) and checked by validation code running in your browser. Nothing is uploaded, and the tool does not call the servers listed in the spec. Internal API specs often describe private endpoints, hosts and data models, so keeping them on your machine matters.

Limitations

  • This is a structural and consistency check, not full JSON Schema validation against the official OpenAPI meta-schema. Some invalid keyword values inside schemas are not reported.
  • Only local references (#/…) are resolved. References to other files or URLs are listed as warnings and not followed.
  • A spec with no errors here can still describe the API incorrectly. Contract tests against the real server are the way to catch that.

FAQ

Which versions are supported?

OpenAPI 3.0.x, OpenAPI 3.1.x and Swagger 2.0. The version is detected from the openapi or swagger field, and the version-specific rules are applied, such as definitions versus components.schemas.

Can I validate a JSON spec?

Yes. JSON is valid YAML, so paste or open a .json file and it is parsed the same way.

What is the difference between errors and warnings?

Errors break the specification rules or leave references that cannot be resolved, which typically breaks tools. Warnings are allowed by the specification but are often unintentional, such as an unused schema or a GET with a request body.

Why is an unused schema only a warning?

Unused schemas are valid and are sometimes kept on purpose for documentation or future use. More often they are leftovers from removed endpoints, so they are worth reviewing.

Does it check that my examples match their schemas?

No. Values in example and examples are not checked against their schemas. Run your examples through a JSON Schema validator in your test suite if you rely on them.

Why does 3.1 allow a spec without paths?

OpenAPI 3.1 made paths optional, so a document can describe only webhooks or shared components for other specs to reference. In 3.0 and Swagger 2.0, paths is required.

Is my API spec uploaded anywhere?

No. Parsing and validation happen entirely in your browser tab, and nothing is sent to a server.

Guides