Open BrandonGoren opened 11 months ago
I'm also bumping into this. Has anyone found a reliable workaround?
I found it helpful to reference enums like:
{
"components": {
"schemas": {
"Person": {
"type": "object",
"properties": {
"Level": {
"allOf": [
{
"$ref": "#/components/schemas/Level"
}
],
"nullable": true
}
}
},
"Level": {
"type": "integer",
"enum": [0, 1, 2, 3, 4, 5, 6, 9]
}
}
}
}
So the Level
enum itself is not nullable, but its reference in Person
schema, is.
@mykeels unfortunately in my case we are consuming another companies api spec. We've had to resort to preprocessing it to effectively do what you described here before passing it to the library
Describe the bug As of 1.11.1, the following command produces an enum that does not work with zod.
Minimal reproduction
Expected behavior The
z.enum
should be nullable, and not include the null value.