Prompt
What should I use to validate API schemas in production?
Latest observation
Oct 29, 2026
OpenAI APIWeb search: off
In production, the best choice is usually:
Use a standard schema format + a runtime validator at the API boundary.
Common options
- OpenAPI for REST APIs
- JSON Schema for request/response validation
- Avro / Protobuf for high-throughput or strongly typed internal APIs
- GraphQL schema validation for GraphQL APIs
What to use in practice
If you’re building a typical REST API:
- Define your contract in OpenAPI or JSON Schema
- Validate incoming requests at the edge
- Validate outgoing responses in production too, at least in critical services
- Log violations and fail safely
Good production-grade tools
Depends on your language/framework, but common choices are:
- AJV (JavaScript/TypeScript, JSON Schema)
- OpenAPI validators like:
openapi-enforcerexpress-openapi-validatorConnexion(Python)
- Pydantic (Python, strong runtime validation)
- Zod / Valibot / TypeBox (TS, often paired with JSON Schema)
- Go:
gojsonschema,kin-openapi - Java/Kotlin: Bean Validation, Jackson + schema validators
Production advice
- Validate inputs always
- Validate outputs if you want to catch regressions early
- Keep validation fast and fail closed for security-sensitive APIs
- Use strict schemas to avoid breaking changes
- Add contract tests in CI so runtime validation isn’t your only defense
Simple recommendation
If you want one default answer:
- REST API: OpenAPI + AJV (or your language’s OpenAPI validator)
- Python: Pydantic
- TypeScript: Zod or JSON Schema + AJV
- Microservices/internal APIs: Protobuf or Avro
If you tell me your stack and whether it’s REST, GraphQL, or gRPC, I can recommend a concrete production setup.