Enums are generated differently between local and kubernetes
RaulRivadeneyra opened this issue · 1 comments
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Context
- One of our processes parses the Swagger Docs generated by @nestjs/swagger.
- We have both a local and a kubernetes environment (Debian Bullseye).
- We have an enum with numeric values.
Issue
When reading the locally generated Swagger Doc, we get an array of strings which the strings are the keys of the enum.
But when reading the Swagger Doc generated in the kubernetes environment we get an array of numbers (the values of the enum).
Example
export class TestDto {
@ApiProperty({
example: 2,
description: 'Test Enum',
enum: TestEnum,
required: true,
})
@IsEnum(TestEnum)
myEnum: TestEnum;
}
export enum TestEnum {
FIRST = 1,
SECOND = 2,
THIRD = 3,
}
Minimum reproduction code
https://gist.github.com/RaulRivadeneyra/314ec78d187e3f16042b4c1bf400fc5b
Steps to reproduce
No response
Expected behavior
We expect that the Swagger Docs generated in the local environment to be the same as the one in Kubernetes.
We are not really concerned about which type is generated, either an array of string or an array of numbers is okay, as long as both environments have the same behavior.
Package version
7.3.1
NestJS version
10.3.3
Node.js version
18.20.4
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
Local Swagger Docs:
"myEnum": { "enum": [ "FIRST", "SECOND", "THIRD" ], "type": "string", "example": 2, "description": "Test Enum"}
Kubernetes Swagger Docs:
"myEnum": { "enum": [ 1, 2, 3 ], "type": "number", "example": 2, "description": "Test Enum"}
Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the # 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.