npm install @ferrow/openapi-breaking-diffCompare two OpenAPI 3 documents and categorize changes as breaking or non-breaking, with JSON paths to each change. Strict TypeScript, zero runtime dependencies.
CI pipelines need a fast, dependency-free way to catch accidental breaking changes between API spec versions — without pulling in a full OpenAPI validation/tooling stack. This library takes plain parsed JSON objects in (you load them however you like) and walks paths, parameters, request/response schemas to flag exactly what broke and where.
import { checkBreaking } from "openapi-breaking-diff";
const { exitCode, result } = checkBreaking(oldSpecJson, newSpecJson);
for (const change of result.breaking) {
console.error(`[${change.kind}] ${change.path} — ${change.message}`);
}
process.exit(exitCode);{ changes, breaking, nonBreaking } — each Change has { category, kind, path, message }.
CI-friendly wrapper: { exitCode: 0 | 1, result }.
BREAKING: removed path/method, new required parameter, request field newly required, request body newly required, removed response field, response removed, schema type change, enum narrowed.
NON-BREAKING: new endpoint/method, added optional parameter/field, response added, enum widened, description changed, request field no longer accepted (server-side relaxation).
- Operates on plain objects you supply — it does not fetch, parse YAML, or resolve
$refpointers. Dereference your spec before diffing if it uses$ref. - Path-level (as opposed to operation-level)
parametersare not merged in; only operation-level parameters are compared. - Schema comparison covers
type,properties,required,enum, anditems— it does not walkoneOf/anyOf/allOfcomposition.
Part of the ferrow-toolkit collection · Sponsored by Ferrow