You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This way, if a default value is provided in the schema object, it won't be ignored. This is a not a huge issue since I can just provide the enum directly into the schema, but if my suggestion makes sense, I could submit a PR. Thanks!
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current behavior
Using the following @ApiHeader() with an enum:
Generates the following OpenAPI schema:
Minimum reproduction code
https://gist.github.com/jointhejourney/13b4cd7feba0864f11c8fd42fd069890
Steps to reproduce
No response
Expected behavior
It should include the default value as provided by the schema, such as:
Package version
7.1.10
NestJS version
9.3.9
Node.js version
18.19.0
In which operating systems have you tested?
Other
This seems to be a fairly straightforward fix, the schema is being overwritten here if an enum is provided:
swagger/lib/decorators/api-header.decorator.ts
Lines 36 to 42 in 5108ba6
Maybe we can do it like this?
if (options.enum) { const enumValues = getEnumValues(options.enum); param.schema = { + ...param.schema, enum: enumValues, type: getEnumType(enumValues) }; }
This way, if a default value is provided in the schema object, it won't be ignored. This is a not a huge issue since I can just provide the enum directly into the schema, but if my suggestion makes sense, I could submit a PR. Thanks!
The text was updated successfully, but these errors were encountered: