-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
7.x nullable enum bug #1564
Comments
@drwpow Isn't it the case that OpenAPI 3.1 no longer supports the
If I add type:
- string
- "null" I do not get a |
In fact it is difficult to find the right information. From my researsh I concluded that, in 3.1:
I got this mostly from this comment: OpenApi is based on JSON Schema, so looking at the enum doc in JSON Schema can help {
"enum": ["red", "amber", "green", null, 42]
} |
|
Again I think this is not clearly forbiden, but the recommanded approach in openapi 3.1 is to:
So: "role": {
"enum": ["orchestrator", null]
} |
Fixed in #1644. Now that I think of it, I do recall a case where someone wanted: type:
- string
- "null"
enum:
- blue
- green
- yellow to generate "blue" | "green" | "yellow" rather than "blue" | "green" | "yellow" | null based on the reasoning that “ Worse-case scenario, you have to handle the null case, and defensive programming isn’t a bad stance to take. |
I am trying to migrate to the v7, I only noticed an issue with nullable enums.
When I run
npx -y openapi-typescript@next test.json > test.ts
on this spec:I get:
For me value should be nullable:
value?: "option1" | "option2" | "option3" | null;
Is it a bug ?
Originally posted by @gduliscouet-ubitransport in #1368 (comment)
The text was updated successfully, but these errors were encountered: