JSON schema validation

JSON schema validation image
JSON schema validation checks that a JSON response or document matches an agreed structure, including which fields exist, their data types and which are required. The expected structure is written as a JSON schema.

Why it matters: Schema checks catch changes to an API's response shape that would break consumers, without needing to assert on every individual value. They act as a safety net for the contract between an API and the applications that use it.

In practice: Teams write or generate a schema for each response, then validate real responses against it in their automated API tests. Many API testing frameworks include schema assertions out of the box.

Examples:

  • Validating every response from an endpoint against its schema in an automated API test suite.
  • Catching a release where a numeric ID quietly became a string.

Common pitfalls:

  • Writing schemas so loose that almost any response passes.
  • Letting schemas drift out of date, so tests check against a structure the API no longer promises.

Is JSON schema validation the same as contract testing? They're related. Schema validation checks the shape of responses. Contract testing goes further, checking that a provider and its consumers agree on how they interact.
Explore MoT
Test Forward 2027 ยท Software Quality in the age of AI image
Tue, 19 Jan 2027
Test Forward is one afternoon at Station F with the QA and engineering people closing that gap in their own teams.
MoT Foundation Certificate in Test Automation image
Unlock the essential skills to transition into Test Automation through interactive, community-driven learning, backed by industry expertise
Into The Motaverse image
Into the MoTaverse is a podcast by Ministry of Testing, hosted by Rosie Sherry, exploring the people, insights, and systems shaping quality in modern software teams.
Subscribe to our newsletter