Answer the question
In order to leave comments, you need to log in
How to describe an object in swagger, for which we do not exactly know the names of the properties?
I get an object of the form: [product name]: DTO with its properties
export class ProductsDto {
[product: string]: ProductDto
}
export class ProductDto {
@ApiResponseProperty()
id: number;
@ApiResponseProperty()
price: number;
}
Answer the question
In order to leave comments, you need to log in
And what prevents you from writing ProductDTO[]
instead of creating a separate DTO? This will also work, or better yet, turn it on in the validation configuration in your application to be sure, so to speak.
If validation is not enabled in your application, then I advise you to do it globally in the filetransform: true
ValidationPipe
для каждого Create
эндпоинта?app.useGlobalPipes(new ValidationPipe({ transform: true }));
@Body() productsDto: ProductDto[]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question