Support for z.lazy()
and recursive schemas
#191
Replies: 4 comments 2 replies
-
@rattrayalex thank you for this. Lazy schemas are something that we do not support at all as of today. I'll take a look at it. |
Beta Was this translation helpful? Give feedback.
-
Would adding if (isZodType(schema, 'ZodLazy')) {
return this.unwrapChained(schema.schema);
} to |
Beta Was this translation helpful? Give feedback.
-
Is this supported now? Or is there a workaround you'd suggest in the meantime for recursive schemas? |
Beta Was this translation helpful? Give feedback.
-
z.lazy is a kind of workaround that allows for manually defining a schema that cannot be computed due to primarily recursions and circular dependencies. |
Beta Was this translation helpful? Give feedback.
-
Currently, this code (copied from zod's recursive types docs):
Throws this error:
Ideally, it would generate an OpenAPI spec like this:
This may require automatic resolution of registered schemas to
$ref
s, which I filed here: #142Beta Was this translation helpful? Give feedback.
All reactions