Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  184] [ 6]  / answers: 1 / hits: 5609  / 4 Years ago, fri, april 10, 2020, 12:00:00

The @nestjs/swagger doc describes here that defining an extra model should be done this way:



@ApiExtraModels(ExtraModel)
export class CreateCatDto {}


But what is ExtraModel here ? The doc is not very clear about this.


More From » swagger

 Answers
2

I ran into the same uncertainity.
After googling https://github.com/nestjs/swagger/pull/355/files I understood the documentation:




  • first import your model to be referred to by import { ExtraModel } from '<filename>' (<--- so this is lacking in the docs BTW)

  • then provide it as param 'ExtraModel' to the decorator

  • the decorator then decorates the class which refers to the model (so providing the reference)



I guess you had the same mind-twister as me that the ApiExtraModels-decorator acts on the model ...



Cheers,
Stephan


[#4199] Wednesday, April 8, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
turnerf

Total Points: 620
Total Questions: 101
Total Answers: 109

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
turnerf questions
;