Why contractdiff
What contractdiff does that oasdiff, Optic and openapi-typescript do not: one model for HTTP, events and agent tools, a stated compatibility question, decisions read from the contract, code generation that knows its own files, and what it leaves out on purpose.
A team with an API contract usually runs three tools on it: one generates types from it (openapi-typescript), one checks changes for breakage (oasdiff, or Optic before it was archived), and one lints it. Each reads the contract its own way, and none of them reads AsyncAPI, an MCP tool list or a JSON Schema the same way it reads OpenAPI. contractdiff is one package that does all three on one model of the contract, and adds the parts none of them has.
What it adds
- One model for every contract. OpenAPI 3.x, Swagger 2.0, AsyncAPI 2.x and 3.x, JSON Schema,
MCP tool lists and protobuf are all read into operations with payloads that travel in a direction.
diff,lint,explain,propsand the generators work on that model, so a breaking change to a Kafka message or an agent tool is caught by the same engine as one to a REST endpoint. See Input formats. - The compatibility question is yours. oasdiff answers for a client that followed the old
contract.
diffasks for the side you name (callerorserver) under the mode you name (backward,forwardorfull), and prints the question on its first line. See Breaking changes. - Usage and history.
--usagelets a breaking change nobody uses pass;--transitivechecks a release against every past one and names the oldest it breaks. - The decision is in the contract.
x-change,x-sunsetandx-replaced-bysit beside the member they are about, anddiffholds every change to them, including a member kept past its sunset. See Decisions. - Code generation that knows its own files.
contractdiff.map.jsonrecords every filegenwrote, so a hand edit is refused instead of overwritten, a removed operation's files are deleted, and a file you own is written once.gen --checkfails CI when generated code is stale. - Validators without eval. The
validatortarget compiles each payload's schema ahead of time with truefit's emitter, so the guards run under a Content-Security-Policy that forbidsnew Function. See The validator target. - The contract tested, not just checked.
propsdraws values from every payload and checks that the validator, JSON round-trip, normalisation anddiff's own verdicts agree. See Property tests. - Every finding names its fix, as the same record in text,
--jsonand SARIF, and the CLI has--schemaand an--mcpserver, so an agent drives it without parsing prose. See Agents. - Dependencies. Four, all in the burgee family (
bellpull,burgee,seniority,truefit), and the generators need no TypeScript compiler.
Where the incumbents are ahead
- oasdiff has years of OpenAPI rules behind it, a composed mode across many spec files, changelog renderings (Markdown, HTML, JUnit), API stability levels and a hosted service. contractdiff uses oasdiff's rule ids for the HTTP changes it names, but whether it finds every change oasdiff finds is unmeasured here.
- Optic captured live traffic into a spec. contractdiff has no traffic recorder.
- openapi-typescript is the reference for its own output. contractdiff's
typestarget andcontractdiff/openapi-typescriptentry follow it, but the compat-oracle host for it isplanned, not graded, so no compatibility is claimed. See Coming from openapi-typescript.
What it leaves out on purpose
- The network. contractdiff reads local files. It does not fetch a spec from a URL, and the
openapiTSentry refuses a remote address with afix:line. - A TypeScript compiler. Types are written as text, which is why
transform,postTransformandtransformProperty, which hand compiler nodes across, are not supported. - A hosted service. No dashboard, no account, no approval gate: exit codes,
--jsonand SARIF, in your own CI. - Guessing. Where the generator had to invent something (a mock body with no example, a contract-test request), it says so as a finding.
What is not built yet
diff git:<ref>:<path>. The argument form is declared, and the 1.0.0 bin refuses it because it does not spawn git yet; write the base out withgit showfirst.check, call sites in code checked against the contract statically, is declared and exits with afix:naming the phase that delivers it.- The NestJS, Hono and tRPC extractors for
extractare not built;standard-schema,openapi-from-schemasandts-restare.
What is not in this page
- Speed. No benchmark of contractdiff against oasdiff or openapi-typescript is recorded in this repository, so there is no speed claim. The family's benchmarks page is where one would appear.
- Adoption. This page names no download or star counts, for either side.
Input formats
contractdiff reads OpenAPI 3.x, Swagger 2.0, AsyncAPI 2.x and 3.x, JSON Schema, MCP tool lists and protobuf into one model, so diff, lint, explain and gen work the same on HTTP APIs, events and agent tools; plus OpenAPI Overlays and explain.
Coming from openapi-typescript
Move from openapi-typescript to contractdiff's types target: contractdiff migrate openapi-typescript turns your script flags and redocly.yaml into a config, contractdiff/openapi-typescript keeps the openapiTS call, and this page says which cases are not covered yet.