-
Notifications
You must be signed in to change notification settings - Fork 474
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
Nullable Enum not generated as nullable #1889
Comments
Let's track this here #2051 |
Can we re-open this issue? The problem is still present in the latest version of this library, and the linked merge request is closed. |
This should be fixed in newer versions of the library. Could you create a separate issue and provide a minimum reproduction repository? |
We're also experiencing this issue on the latest version of the library. The problem is that when you name the enum, Nest is extracting the enum into a shared type (with objects:
Enum:
type: string
values:
- One
- Two
MyApiObj:
properties:
someField:
$ref: objects/Enum
nullable: true OpenAPI treats If you don't supply a name to the It looks like Nest added support for the nest compiler to generate unnamed nullable enum types as described above, but not named types. Though, if the named enum is used in difference contexts (one nullable, one not) you really can't extract to a shared named type, unless using OpenAPI 3.1.x semantics for nullable properties, i.e. objects:
Enum:
type: string
values:
- One
- Two
MyApiObj:
properties:
someField:
oneOf:
- $ref: objects/Enum
- type: 'null' |
Spent today more than one hour dealing with the issue perfectly described by @mothershipper 🔝 : when the |
Would be nice to get a fix for this, I also just ran into the same behavior. |
This seems to be fixed by adding the following lines to const wrappedRef = metadata.nullable ? { allOf: [{ $ref }] } : { $ref };
const refHost = metadata.isArray ? { items: wrappedRef } : wrappedRef; |
Hi, i still have the issue, could you fix it? |
Any update ? |
It should be fixed in the latest version. If you run into any issues, please create a new issue with a reproduction repository |
Is there an existing issue for this?
Current behavior
Using the following annotation:
openapi-generator 5.4
generates:I need to use the following workaround to get it nullable:
=>
Minimum reproduction code
https://github.com/jbdemonte/issue-nestjs-openapi-generator-nullable-enum
Steps to reproduce
npm install
npm run generate:angular-client
Expected behavior
the exported
value
type should bevalue!: FooBarEnum | null;
Package version
5.2.1
NestJS version
8.4.4
Node.js version
16.13.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: