// input text will have `something` as value
@ApiPropertyOptional({
default: 'default is ignored',
description: 'some string',
example: 'something',
})
q?: string;
// No option selected but the request will include `?options=one`
@ApiPropertyOptional({
description: 'some options',
enum: OPTIONS,
example: OPTIONS[0],
isArray: true,
})
options?: (typeof OPTIONS)[number];
Expected behavior
Default values in SwaggerUI should not be taken from the example property but from the defaultif there is any
Is there an existing issue for this?
Current behavior
The Swagger page is taking default values from the
example
property in the declaration.This is especially an issue when the property is an array due to there is no way to really not sent the query param:
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-aprkdl?file=src%2Fapp.controller.ts
Steps to reproduce
Declare an optional property as in:
Expected behavior
Default values in SwaggerUI should not be taken from the
example
property but from thedefault
if there is anyPackage
Other package
@nestjs/swagger
NestJS version
9.0.0
Packages versions
Node.js version
v18.16.0
In which operating systems have you tested?
Other
No response