Skip to main content
Community
Q&A

JSON schema validation — jsonschema vs pydantic vs just asserting against the OpenAPI spec?

Ajitesh Mohanta
Ajitesh MohantaAmbassador
May 9, 2026 927 0
I need to validate API response structures in pytest tests. Three paths I see: 1. `jsonschema` — explicit, dict-based schema definitions, verbose 2. `pydantic` — nice Python models, easy to assert on attributes, but doubles as production code 3. `openapi-core` or `schemathesis` — validate against the actual OpenAPI spec, most truthful I lean towards option 3 because it means the spec IS the contract. But `schemathesis` feels like a different paradigm (property-based testing) rather than targeted assertions. What do you use for API response validation in your test suite?

No replies yet. Be the first to answer this question!

Join the discussion

Sign in to join the discussion

Sign in
JSON schema validation — jsonschema vs pydantic vs just asserting against the OpenAPI spec? — Community | QABash