You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Swagger 2.0, there is no way to represent that a type is "nullable", i.e., that null is a valid value to pass to it (like nullable in Openapi 3.0.x).
What is the feature you are proposing to solve the problem?
A common convention is to use x-nullable to represent this instead. I would like it if kubb supported this (specifically, for swagger-zod).
I recently implemented this in openapi-typescript: openapi-ts/openapi-typescript#1576, and need this feature to maintain feature parity (currently we cannot use these zod schemas as they miss this crucial feature). If approved, I would make the PR to support it here.
The core of the change would effectively be changing this:
I think to solve this, we would need to resolve this issue (kogosoftwarellc/open-api#768) in openapi-types first, though
Edit: I raised a PR; kogosoftwarellc/open-api#899, but also I think we need to bump the package in oas as well. That is, if it gets merged ever, I don't know how actively maintained it is 😄
To be clear, I think this needs this PR since otherwise it thinks that the schemas can't have x-* fields, so we can't check x-nullable without a ts-ignore comment.
@mitchell-merry It would of course be nice if this could be fixed in oas but I will open a PR that will add the logic you suggested const nullable = (schema.nullable || schema["x-nullable"]) ?? false so the issue here will be resolved :)
What is the problem this feature would solve?
In Swagger 2.0, there is no way to represent that a type is "nullable", i.e., that
null
is a valid value to pass to it (likenullable
in Openapi 3.0.x).External documents/projects?
No mention of
nullable
in the 2.0 spec: https://swagger.io/specification/v2/nullable: true
is how it is done in 3.0.x: https://swagger.io/docs/specification/data-models/data-types#null(3.1.x uses an
anyOf
withnull
)What is the feature you are proposing to solve the problem?
A common convention is to use
x-nullable
to represent this instead. I would like it if kubb supported this (specifically, forswagger-zod
).I recently implemented this in
openapi-typescript
: openapi-ts/openapi-typescript#1576, and need this feature to maintain feature parity (currently we cannot use these zod schemas as they miss this crucial feature). If approved, I would make the PR to support it here.The core of the change would effectively be changing this:
to this (but exposed as an option):
What alternatives have you considered?
Upgrading to 3.1.x... but that is impossible for a number of reasons right now 😅
The text was updated successfully, but these errors were encountered: