API and code generation

JSON Schema vs. OpenAPI Schema

Both describe JSON, but their goals, supported keywords, and toolchains differ.

Start with the goal

JSON Schema describes whether an instance satisfies constraints. OpenAPI Schema describes HTTP API inputs and outputs alongside paths, parameters, responses, and security.

Why conversion is not lossless

OpenAPI versions do not support every JSON Schema keyword in the same way. Check references, combinations, defaults, and nullable semantics for the target version; generated code still needs compilation and API tests.

A safer workflow

Choose the target OpenAPI version or JSON Schema draft first, generate types, then validate real responses and negative cases. A sample JSON document is not a complete contract.

Related tools

Sources

Last updated: 2026-08-23