#Using generics inside type of swagger nestjs
4 messages · Page 1 of 1 (latest)
two approaches:
A DTO (Data Transfer Object) is a design pattern used to encapsulate and transfer data between different layers or components of an application. The
Jeez thanks a lot the second approach was the solution that I needed, as we already talking about swagger and nest. I have a lot of validators exception that can be throwed with a lot of different messages.
ApiUnprocessableEntity({type: ValidationSwagger})
and i create example for each one, like name invalid, or email invalid. Passing as parameters to the validationSwagger that is an objectDto mapped with ApiProperty()
Inspired on https://github.com/nestjs/swagger/issues/2260 , the request said that wanted to do something like
@ApiOkResponse({
type: CatDTO,
isArray: true,
example: [{
name: 'Tom'
}]
})
But i didn't find any material that is updated to this usecase