A JSON Schema is itself a JSON document that states the rules another document must follow: its type, which properties it has, which are required, what types and formats their values take, how long strings and arrays may be. Validators in every major language check a document against a schema and report each violation.
Keywords such as type, properties, required, items, enum, format and pattern combine to describe a shape; $ref reuses definitions. OpenAPI 3.1 uses JSON Schema (draft 2020-12) for its request and response bodies, so an API description is also a set of validators for its own traffic.
That additionalProperties defaults to false. By default a schema allows properties it does not mention, which means a response full of unexpected fields still validates. Strict contract checks have to say additionalProperties: false — or accept that extra fields are not being caught.
Each API's OpenAPI document embeds JSON Schemas for its bodies; paste a response from Try it out into the sibling site's JSON to JSON Schema generator to get a schema inferred from the data itself.
All glossary terms · Testing techniques · All 39 mock REST APIs
Last updated