Skip to content

covenix / toJsonSchema

Function: toJsonSchema() ​

toJsonSchema(schema): JSONSchema

Defined in: src/swagger.ts:76

Converts a single Zod schema to its JSON Schema representation. Nested schemas named via .meta({ id }) are emitted as $refs into a $defs block; the doc assembly step rewrites those references for OpenAPI components.

Parameters ​

schema ​

ZodType

The Zod schema to convert.

Returns ​

JSONSchema

The schema as JSON Schema (draft 2020-12).