Browser-based spec comparison · specs are read here, never sent

OpenAPI Diff

Compare two OpenAPI 3.x or Swagger 2.0 documents and see which changes would break an existing client: removed operations, new required parameters, changed types, removed enum values, dropped responses and tightened security. Request and response schemas are judged separately.

The two specs

Drop the old spec

The version clients use today, up to 5 MB

Drop the new spec

The version you plan to release, up to 5 MB

Only local #/ references are followed. References to other files or URLs are not fetched, and the report says when that left schemas uncompared.

OpenAPI Diff: Find Breaking Changes Between Two Specs

Operator: Abdulla Al Fahad. How tools are built and checked

Changing an id from an integer to a string is a one-line edit in a spec and a crash in every client that parses it as a number. Paste the old and the new OpenAPI or Swagger document here and each difference is listed with a level: breaking, risky or non-breaking, from the point of view of a client that already ships.

The built-in example is a small pet store. Between its two versions the page finds 13 differences: 6 breaking (a deleted operation, a new required query parameter, a new required request field, a changed security scheme and an id that changed type in two responses), 1 risky and 6 non-breaking. The same edit is not judged the same way everywhere, because a field a client sends and a field a client reads follow opposite rules.

Key features

  • Compares OpenAPI 3.x and Swagger 2.0 documents in JSON or YAML, including one of each
  • Three levels per change: breaking, risky and non-breaking, with the operation and the exact place in the schema
  • Request-side and response-side schemas judged by different rules
  • Path parameters renamed between versions matched up instead of reported as a removed and an added path
  • Markdown changelog and JSON report, ready for release notes or a CI step

How each change is judged breaking, risky or safe

Operations are matched on the method plus the path template with every {name} treated as the same placeholder, so /pets/{petId} in the old spec and /pets/{id} in the new one are the same operation and only a non-breaking rename is reported. Parameters are matched on location plus name (header names ignoring case). Responses are matched on status code, media types on their type without parameters such as charset.

Only local references (#/components/..., #/definitions/...) are followed, to a depth of 12 levels, with reference loops detected. allOf parts are merged before comparing; oneOf and anyOf variants are matched by the name of the schema they reference, or by title, or by position. A reference to another file or URL is never fetched: the page says so and leaves those schemas uncompared. A schema that is reached again through the same pair of nodes, as a self-referencing allOf is, is compared once. Each spec may be up to 5 MB and 2,000 operations. Comparing stops after 9,000 raw changes; the list is then sorted breaking first and cut to 3,000, and the counts at the top are taken before the cut, so a flood of minor changes cannot push a breaking one out.

How it works

Both documents go through the same parser as OpenAPI Docs Generator here, which normalises OpenAPI 3 and Swagger 2 into operations, parameters, bodies and responses. The diff then walks each pair of matched operations.

For a schema the direction decides the verdict. A client sends request fields, so a new required property, a narrower type, a removed enum value or a tightened limit (a lower maximum, a higher minimum) is breaking, while a loosened rule is safe. A client reads response fields, so a removed property, a different type or a property that stopped being required is breaking, and a new enum value or a loosened limit is risky because a client with a closed switch or a fixed-size field may not expect it.

Common use cases

  • A platform team gates releases on the JSON report: a pull request that adds anything under breaking has to bump the major version, while 40 non-breaking additions pass without a conversation.
  • A consumer team receives v2 of a partner API and filters the report to the three operations it calls, finding that one response status it handled, 404, was removed and one enum value it switches on was dropped.

How to use this tool

  1. Drop or paste the spec your clients use today in the left box and the spec you plan to release in the right box.
  2. Press Compare specs and read the three counts at the top; the list is sorted breaking first.
  3. Filter by level, or type part of an operation, a field name or a status code into the filter box.
  4. Open the Markdown tab to copy the changelog, or the JSON tab for a machine-readable report.

Example

Three of the 13 differences in the built-in example, from GET /pets and POST /pets

Old: GET /pets has an optional limit query parameter; the response id is an integer; POST /pets needs only name.
New: GET /pets also requires an owner query parameter; the response id is a string; POST /pets also requires species.

Changes the page lists

breaking  GET /pets  parameter query owner: Required query parameter owner was added.
breaking  GET /pets  response 200 application/json at $[].id: Type changed from integer to string.
breaking  POST /pets  request body application/json at $.species: Request property species was added and is required.

Common pitfalls

The comparison is structural. Descriptions, examples, tags, info.version and component schemas that no operation uses are not compared, so a rewrite of documentation shows no differences and a schema nothing references shows none either.

Risky is a judgement, not a defect: removing an optional request parameter only breaks clients if the server rejects unknown parameters, and a new response enum value only breaks clients that switch exhaustively. Decide those two by what your servers and clients really do.

Behaviour that a spec cannot express, such as a field changing meaning while keeping its type, is invisible to any diff of the document.

  • Compare the spec your clients were generated from, not the previous commit: the verdict is about the clients that exist, so an intermediate draft can hide a break that was already published.
  • Filter on a field name such as status to see every operation that shares a changed schema; one edit to a shared component appears once per operation that uses it.

Common errors and how to fix them

"Old spec: Invalid YAML at line 14, column 3" (or the same for the new spec)
The message names which box failed and where. A tab character used for indentation and a missing space after a colon are the usual causes; JSON specs report the position of the first bad character instead.
"OpenAPI 4.0.0 is not supported. This page reads OpenAPI 3.x and Swagger 2.0."
Only the openapi field values starting with 3. and the swagger value "2.0" are read. A document with neither field is reported separately as not being an OpenAPI or Swagger document.

Best practices

  • Treat any change classified as breaking in a response schema as a new API version unless every known client has been checked, and record the decision next to the Markdown changelog.

How the levels are assigned

Breaking means a correct existing client fails: an operation or path removed, a success (2xx) response removed, a media type no longer accepted or returned, a required parameter or request property added, an optional one made required, a type changed to something that is not a superset, an enum value removed from a request, a security requirement added where there was none, or every accepted authentication alternative replaced.

Risky means a client may fail depending on the server or on how it was written: an optional parameter or request property removed, a non-success response removed, a response header removed, a new enum value or oneOf variant in a response, a changed format or pattern, a changed operationId (generated SDK method names move), and a change of server URLs. Everything else is non-breaking, including added operations, added optional parameters, new response properties and deprecations.

Frequently asked questions

Why is a new response property non-breaking but a removed one breaking?

A client that ignores unknown fields is unaffected by an extra one, while a client that reads a field that has vanished gets nothing. The page assumes clients tolerate extra response fields; a client that validates responses strictly against the old schema would disagree.

Can it compare a Swagger 2.0 file with an OpenAPI 3 file?

Yes, both are normalised first and a warning notes that the formats differ. Format-only differences, such as how a request body or server list is written, can still hide or add small differences, so check the servers and body rows when you migrate.