ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and shared lessons, time-to-delivery measurement, a library of 140 verification techniques and 20 recipes, personal data kept outside the clone, and releases with rollback. Standard library only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
3.0 KiB
3.0 KiB
id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
| id | title | answers | rung | section | languages | kinds | cost | detect | ran_here | verified |
|---|---|---|---|---|---|---|---|---|---|---|
| api-breaking-schema | Breaking-change checks for protobuf, OpenAPI and GraphQL schemas | Did my schema change break existing clients of this API? | 4 | regression | any | general, migration | low | buf --version | no | docs |
Use when
- You edited a
.protofile, an OpenAPI document or a GraphQL schema that other code or other teams consume. - You must show a change is additive, not breaking.
Do not use when
- The schema is internal and changes with all its users in one commit; a compile is enough.
- You need runtime behaviour: see
contract-testing-pactinreal-world/.
Set up
- Protobuf: install
buf(https://buf.build/docs/installation) and keep abuf.yamlat the module root. - OpenAPI: install
oasdiff(Go binary or Docker image). - GraphQL:
npm i -D @graphql-inspector/cli graphql. Each tool compares the working tree to a known-good base: a git ref or a saved copy of the old schema.
Minimal example
buf breaking --against '.git#branch=main' # protobuf, against the main branch
oasdiff breaking --fail-on ERR base/openapi.yaml openapi.yaml # OpenAPI; first arg is the old spec
graphql-inspector diff base/schema.graphql schema.graphql # GraphQL; reports breaking, dangerous, safe
Get the base BEFORE editing: git show main:api/openapi.yaml > /tmp/base-openapi.yaml. Use --fail-on WARN with oasdiff to also fail on risky changes. buf has rule sets (FILE, PACKAGE, WIRE_JSON, WIRE) set under breaking: in buf.yaml; pick the one that matches how clients are built.
Run
Any of the commands above.
Passing looks like: no output and exit 0 from buf breaking; oasdiff exits 0 with no error lines; graphql-inspector says no breaking changes. Failure: buf prints file:line:col:message for each break and exits 100; oasdiff with --fail-on ERR exits 1 and lists each change with an id; graphql-inspector exits 1 on breaking changes.
As a contract check
{"id": "api-schema-compat", "claim": "The OpenAPI spec has no breaking changes against main", "kind": "general", "rung": 4,
"cmd": "git show main:api/openapi.yaml > /tmp/base.yaml && oasdiff breaking --fail-on ERR /tmp/base.yaml api/openapi.yaml", "expect": {"exit": 0}, "tier": "deep", "timeout_s": 120}
What a pass does not prove
- Only the schema, not the server. A server can stop matching its own spec; test that separately (
contract-testing-pact, schema-validating end-to-end tests). - Semantics are invisible: renaming meaning without renaming a field passes.
- Not run here (the tools are not installed).
buf breaking --againstandoasdiff breaking --fail-on ERRare from their READMEs; the graphql-inspector command and buf's exit code 100 are from memory and should be checked with--help. - Comparing to the wrong base (your own branch) always passes. Check the base is the released one.
- Check the check: remove a field in a scratch copy and confirm it reports a break.