Skip to main content

How do you validate JSON schema in API tests?

  • JSON schema
  • validation
  • response verification

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Use JSON Schema validation libraries (Ajv for JavaScript, jsonschema for Python) to verify response structure: required fields present, correct data types, string formats (email, date-time, UUID), enum values, and array item types. Store schemas as files and validate every API response against them. This catches breaking changes early, a removed field or type change fails the schema check even if the endpoint returns 200.

What interviewers listen for

  • Schema-first thinking
    You validate response shape before you assert on values, every time.
  • Status-code literacy
    You can defend why 401 vs 403 vs 422 matters for the consumer.
  • Contract awareness
    You know when consumer-driven contract tests beat end-to-end checks.
  • Auth fluency
    You can describe rotating tokens across parallel workers without secrets in logs.

See all 35 api testing questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026