-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
z.nullable
does not use schema references
#141
Comments
z.nullable
causes schema reference to not be includedz.nullable
does not use schema references
@FelixZY thanks for bringing this up. |
@FelixZY I took a look at your example. And actually we already support that. The result has |
There is a bug in `asteasolutions/zod-to-openapi` where `z.nullable(schema)` can cause the full object to be output instead of the expected `$ref`. Using `schema.nullable()` was proposed as a workaround: asteasolutions/zod-to-openapi#141 (comment)
This turned out to be impossible with the current way of implementing such methods. Because of that I've just updated the README.md file with a note for it (that |
I have a schema like this:
Which causes an annoying difference when rendered:
It seems the reason for this is that the openapi spec generated for
z.array
useswhereas the openapi spec generated for
z.nullable
does not use$ref
(tested for openapi3.0.3
and3.1.0
):Would it be possible to get
z.nullable
to generate a$ref
as well? Perhaps usingoneOf
?The text was updated successfully, but these errors were encountered: