ppetzold/nestjs-paginate

Anyway to override the Example text in the generated Swagger output?

Opened this issue · 3 comments

cuda commented

Hi All,

Is there any way to override the Example text in the generated Swagger output?

For example,
image

Here, the filter only supports $eq, and I want to add a relevant example, such as:
Example: filter.service=$eq:SMS

Thanks,
Marcus

cuda commented

Adding a @apiquery after @ApiPagniationQuery seems to do work

@ApiPaginationQuery(RecipientPaginationConfig)
@ApiQuery({
    name: 'filter.service',
    required: false,
    type: String,
    isArray: true,
    description: `Filter by id query param.
          ${p('Format', `filter.service={$not}:OPERATION:VALUE`)}
          ${p('Example', `filter.service=$eq:SMS`)}
          ${li('Available Operations', ['$eq'])}`
  })

(of course, defining the functions p and li as in lib)

This overwrites the generated one in the output

Minor hiccup: If you don't override all the filters, they are not listed together, with a page and limit between the ones you overwrote and the ones you generated.

Helveg commented

@vsamofal and I are recently onboarded contributors, and as far as I understand it @vsamofal is the one that drove development of the Swagger parts. I'm still getting introduced to the matter, but willing to learn. I'm currently stuck on #883. If either of you could help me get acquainted with NestJS' Swagger, then I can have a deeper look at this issue and we can think of a clean solution for this.

Helveg commented

Currently, by looking at the source code, there is no way provided by the package to override this. Perhaps we can provide more fine grained decorators, or configuration to the decorators, for overriding parts of the Swagger output?