Blog
OpenAPI Contract Testing: Documentation Must Be Executable
An OpenAPI file that says amount is a number while production returns a string is not documentation. It is a confident lie consumed by code generators.
Pick A Source Of Truth
Design-first and code-first can both work. The failure is allowing annotations, YAML, generated clients, and real responses to evolve independently.
Run schema validation against representative integration-test responses. Validate error responses too; happy-path drift is not the only contract break.
Check Compatibility In CI
Compare the proposed specification with the released version. Removed operations, required new fields, narrowed enums, changed formats, and response-code changes deserve explicit review.
The OpenAPI Specification treats operationId as a unique operation identifier. Keep it stable when generated clients use it for method names.
Examples Need To Survive
Turn documented examples into test fixtures or generate fixtures from validated schemas. A copied example containing an old enum trains clients to fail.
OpenAPI cannot express every semantic rule. Add prose and executable domain tests for idempotency, ordering, and cross-field constraints. A schema is one contract layer, not whole system.