API contracts

JSON Schema for reliable API contracts

A schema workflow that treats successful and failing payloads as executable documentation rather than relying on one ideal sample.

JSON syntax only proves that a document can be parsed. A useful API contract must describe which structures and values consumers may safely expect.

Model absence and null explicitly

Required, optional, and nullable are different states. Define types, array items, enums, formats, bounds, and additionalProperties according to actual compatibility rules.

Test failures as well as success

Keep examples for missing fields, wrong types, nulls, unknown enum values, extra properties, empty arrays, and every oneOf or anyOf branch.

Manage contract evolution

Compare schemas and real payloads during releases, distinguish additive from breaking changes, and generate client types only as a reviewed starting point.

API schema checklist

  • Define required optional and nullable fields
  • Constrain arrays enums and formats deliberately
  • Add representative invalid examples
  • Review oneOf and anyOf overlap
  • Test schema changes against real payloads

Related guides

Learn the workflow behind this tool and what to check next.

Related tools