Agent renamed an API field? oasdiff shows which clients break
oasdiff compares two OpenAPI specs and fails CI when a change breaks existing clients.
Published here · 4 sources · Resume reading
An AI coding agent renamed an API field. The server accepted it, but every client using the old name failed. oasdiff catches this by comparing two OpenAPI specs and listing what breaks existing clients [1].
Run a breaking change check
oasdiff breaking base.yaml revision.yamlExit code 0 means no breaking changes. Exit code 1 means at least one [2].
Fail CI on breaking changes
Add --fail-on ERR to exit 1 on errors, or --fail-on WARN to include warnings [4]:
oasdiff breaking --fail-on ERR base.yaml revision.yamlYou should see either a clean exit or a list of breaking changes with their severity.
Add it to GitHub Actions
The oasdiff action compares your PR branch against the base branch and posts inline annotations [3]:
name: oasdiff
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
breaking-changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: git fetch --depth=1 origin ${{ github.base_ref }}
- uses: oasdiff/oasdiff-action/breaking@v0
with:
base: 'origin/${{ github.base_ref }}:openapi.yaml'
revision: 'HEAD:openapi.yaml'
fail-on: WARN
github-token: ${{ github.token }}Replace openapi.yaml with your spec path.
What oasdiff calls breaking
oasdiff checks what the contract declares, not what a server happens to accept. A required field is breaking even if your server has a default, because API gateways and generated SDKs enforce the spec [4]. Changes flagged as ERR are definite breaks. Changes flagged as WARN are potential breaks that cannot be confirmed without more context.
The full check list is in the oasdiff documentation [4]. For the plain definition of an API contract before you wire CI, see what is an API.
Send this to the teammate whose agent renamed an API field and broke every client.
Keep this guide
Filed under Dev tools
Questions about this guide
What counts as a breaking change?
Anything that makes a valid request under the old spec invalid under the new one. Adding a required field, removing an endpoint, or changing a response schema are common examples.
Does it catch warnings too?
Yes. Use --fail-on WARN to fail on warnings, or --fail-on ERR to fail only on errors.
Sources
- oasdiff GitHub repositorygithub.com
- oasdiff CLI quick startoasdiff.com
- oasdiff GitHub Actionoasdiff.com
- oasdiff breaking changes documentationgithub.com