OpenAPI diff and breaking changes
Runs in your browser. Nothing is uploaded.
Compare two versions of an OpenAPI file and see what changed, with the changes that break clients listed first.
Ctrl/⌘+Enter runs again
Old version
103 lines
openapi: "3.1.0"
info:
title: Petstore
version: 1.0.0
description: A sample API that uses a pet store as an example.
license:
name: MIT
identifier: MIT
servers:
- url: https://petstore.example.com/v1
tags:
- name: pets
description: Everything about your pets
paths:
/pets:
get:
summary: List all pets
description: Returns the pets in the store, a page at a time.
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
"200":
description: A page of pets
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
tags:
- store
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"201":
description: The pet was created
/pets/{petId}:
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
responses:
"200":
description: The pet
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
New version
87 lines
openapi: "3.1.0"
info:
title: Petstore
version: 1.0.0
description: A sample API that uses a pet store as an example.
license:
name: MIT
identifier: MIT
servers:
- url: https://petstore.example.com/v1
tags:
- name: pets
description: Everything about your pets
paths:
/pets:
get:
summary: List all pets
description: Returns the pets in the store, a page at a time.
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
"200":
description: A page of pets
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: Unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
tags:
- store
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"201":
description: The pet was created
components:
schemas:
Pet:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
birthDate:
type: string
format: date
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
type: object
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Changes
Paste, upload or load a file to start
How it works
Put the old version on the left and the new one on the right: paste, upload or load each from a URL. The page
bundles both and compares them with the engine of apigit diff, about half a second after you stop typing. Breaking
changes come first, each with where it is and what changed.
The sample pair is a pet store and the same API after GET /pets/{petId} was removed and an optional birthDate
was added to Pet:
1 breaking, 1 other change
Breaking 1
GET /pets/{petId} operation removed
Other changes 1
schema Pet schema field "birthDate" added
The removed operation breaks every client that calls it. The new optional field does not: old clients ignore it.
What it does not do
- It compares OpenAPI documents only; an AsyncAPI document or a GraphQL schema is refused.
- It does not read a Git history. Give it two files, or the URLs of two versions (raw files of two tags or branches); the CLI compares commits, branches and tags directly.
- It does not judge intent: a change listed as breaking may be one you meant to make. Decide, then version the API accordingly.
- A
$refto another file of a pasted spec is not followed; load the versions from URLs to resolve relative references on the same host.
This tool and APIGit
| This tool | With APIGit |
|---|---|
| Two files at a time | apigit diff main HEAD openapi.yaml between any two commits, branches or tags |
| Breaking changes listed | apigit breaking exits 1 on a breaking change, so CI stops the merge |
| Run by hand | The GitHub Action apigitlabs/apigit-action@v1 with run: breaking origin/main HEAD openapi.yaml |
| Compare two pasted files | The editor's Diff view shows your uncommitted changes beside the committed file |
| One diff | Every change reviewed in a pull request, with the spec rendered from the same repository |
Questions and answers
What counts as a breaking change?
A change that can make an existing client fail: an operation, a response or a schema removed, a required parameter or request field added, a response field removed, a type changed. The diff lists these first, under Breaking, and the rest under Other changes.
Is it the same engine as apigit diff?
Yes. The page runs the diff engine of the APIGit CLI in your browser. Like apigit diff, it bundles both documents first, so references to other files are resolved and named schemas are compared once.
Can I compare Swagger 2.0 or AsyncAPI files?
Both inputs must be OpenAPI documents (an openapi or swagger field). An AsyncAPI document is refused with a message; the CLI's diff and breaking are OpenAPI-only too.
How do I share a diff?
Load both versions from URLs (for example the raw files of two Git tags), then click Share. The link carries the two addresses, never the files, and the reader's browser fetches both.
Can I fail a build on a breaking change?
Yes, with the CLI: apigit breaking origin/main HEAD openapi.yaml lists only the breaking changes and exits 1 when there is one. The GitHub Action runs the same command.
Are my files uploaded?
No. Both files stay in your browser; only a URL you load is fetched, by your browser, from the host you named.