Swagger module need at least one decorator in a class to correctly decorate classes with @nestjs/swagger/plugin
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;
}
Should add ApiProperty automatically to all fields.
When no decorator is provided at all NestJS doesn't decorate the class.
Add one fake decorator on any field :-)
Nest version: 6.10.5
"nestjs/swagger": "4.0.2",
For Tooling issues:
An issue in model-class.visitor.ts visit() method ?
Fixed in 4.0.6 :)
You rock Kamil :-)
@kamilmysliwiec I am on "version": "4.0.9", and this still seems to be an issue. Is there a link to the commit and regression tests that resolved this?
4.0.9 is fine for me after updating. Have to tried to remove cache, node_modules, ... ?
Here is the commit => https://github.com/nestjs/swagger/commit/e468b1b2e5a1faf1acd3f91aecfb4db79a9c513e
Using @nestjs/swagger:^4.3.2, still facing the issue.
Using @nestjs/swagger: 4.5.7, same issue, thankfully just throwing a single @ApiProperty on any field for my entity let it generate the types for all other properties. My entities were not picked up even with the proper suffix. If you have in-line DTO's then they only way forward is to put @ApiProperty on all the properties OR move them into .dto.ts files. I think you still have to put at least 1 @ApiProperty on it but I think any class-validator's will cause it to be picked up. Which makes sense as I don't use any class-validator annotations on my actual entities (models). It needs at least something in the file to pick up it appears.
Please, create a separate issue with a reproduction repository linked.