@nestjs/swagger/plugin requires at least one decorator in the class to generate ApiProperty automatically
See original GitHub issueBug Report
Current behavior
Swagger module need at least one decorator in a class to correctly decorate classes with @nestjs/swagger/plugin
Step to reproduce
Take the default E2E sample (cats) provided in @nestjs/swagger/plugin. Remove all class-validator decorators.
export class CreateCatDto {
readonly name: string;
readonly age: number;
readonly breed: string;
}
Expected behavior
Should add ApiProperty automatically to all fields. When no decorator is provided at all NestJS doesn’t decorate the class.
Possible Solution/Workaround
Add one fake decorator on any field 😃
Environment
Nest version: 6.10.5 “nestjs/swagger”: “4.0.2”,
For Tooling issues:
- Node version: latest
- Platform: Windows
An issue in model-class.visitor.ts visit() method ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Why are types in dto not visible in swagger? - Stack Overflow
Create DTO without types, but matches type/interface structure just ... you deocorate at least one entry of your dto with @ApiProperty() ...
Read more >Types and Parameters - OpenAPI - Documentation | NestJS
Types and parameters. The SwaggerModule searches for all @Body() , @Query() , and @Param() decorators in route handlers to generate the API document....
Read more >What's new in NestJS Swagger 4? - Trilon Consulting
The plugin adds appropriate decorators on the fly based on the Abstract Syntax Tree. Hence, you no longer have to struggle with @ApiProperty...
Read more >Integrating Swagger/OpenAPI with NestJS - codeburst
Automatically apply the ApiProperty() decorator to class fields (the class must have a file name of *.dto.ts or *.entity.ts ); Determine whether ...
Read more >Bountysource
nestjs/swagger/plugin requires at least one decorator in the class to generate ApiProperty automatically.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in 4.0.6 😃
Using
@nestjs/swagger:^4.3.2
, still facing the issue.