swagger
swagger copied to clipboard
Nullable Enum not generated as nullable
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
Using the following annotation:
export class ClientResponseDto {
@Expose()
@ApiProperty({ enum: PaymentTermsEnum, enumName: 'PaymentTermsEnum', nullable: true })
paymentTerms!: PaymentTermsEnum | null;
}
openapi-generator 5.4
generates:
export interface GetClientByIdResponseDto {
paymentTerms: PaymentTermsEnum;
I need to use the following workaround to get it nullable:
export class ClientResponseDto {
@Expose()
@ApiProperty({ oneOf: [{ type: 'enum', $ref: 'PaymentTermsEnum', nullable: true }] })
paymentTerms!: PaymentTermsEnum | null;
}
=>
export interface GetClientByIdResponseDto {
paymentTerms: PaymentTermsEnum | null;
}
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 be value!: 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?
- [X] macOS
- [ ] Windows
- [ ] Linux
Other
No response