basalt / fastify/src / zodToJsonSchema
Function: zodToJsonSchema()
> zodToJsonSchema(schema): JsonSchema
Defined in: http/src/openapi.ts:17
Zod → JSON Schema (OpenAPI 3.0 dialect), delegating to Zod's own converter.
Until zod 4 became the requirement this function also carried a hand-rolled switch over _def.typeName for zod 3, which the native converter replaces outright. Unknown types still degrade to {} rather than throwing: an OpenAPI document missing a constraint is far better than a boot that fails.
Parameters
schema
ZodTypeAny
Returns
JsonSchema