The fields of DTO do not appear in Swagger UI when using CLI.
Alivers opened this issue · comments
Aliver commented
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
With the following codes, the swagger docs don't work as expected.
--- user.dto.ts ---
export class GetUserDto {
/**
* The unique id of the user.
* @example "1234"
*/
userId: string;
}
--- user.controller.ts ---
@Controller('user')
export class UserController {
@Post('get')
async getUser(@Body() param: GetUserDto) {
return { userId: 'test' };
}
}
--- nest-cli.json ---
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"generateOptions": {
"spec": false
},
"compilerOptions": {
"plugins": [
{
"name": "@nestjs/swagger",
"options": {
"classValidatorShim": true,
"introspectComments": true
}
}
]
}
}
Minimum reproduction code
https://github.com/Alivers/nestjs-template
Steps to reproduce
pnpm install
pnpm start:dev
Expected behavior
Show correct fields and descriptions based on the comments on Swagger UI
Package version
7.3.1
NestJS version
10.3.2
Node.js version
20.11.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Aliver commented
After changing the repo to standard
(non-monorepo), It works as expected.