scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.41k stars 225 forks source link

Missing location (in) when using with applyDecorators #281

Closed mashirozx closed 2 years ago

mashirozx commented 2 years ago

I'm combining decorators in meddileware:

import { applyDecorators } from '@nestjs/common'
import { ApiQuery } from '@nestjs/swagger'

/**
 * Combines pagination related @ApiParam decorators.
 */
export const ApiPaginationParam = () => {
  return applyDecorators(
    ApiQuery({ name: 'take', required: true, type: Number, description: 'Pagination per page' }),
    ApiQuery({ name: 'skip', required: true, type: Number, description: 'Pagination page' })
  )
}

And the controller:

class controller{
  @Get()
  @ApiOperation({ summary: 'Get users list' })
  @ApiPaginationParam()
  async findAll(@Query() { take, skip }) {
    return pagedOutput(await this.usersService.findAll({ take, skip }))
  }
}

I'll get: image

But I need the parameters in the query, not only in path.

When using the normal way:

class controller{
  @Get()
  @ApiOperation({ summary: 'Get users list' })
  @ApiQuery({ name: 'take', required: true, type: Number, description: 'Pagination per page' })
  @ApiQuery({ name: 'skip', required: true, type: Number, description: 'Pagination page (begin from 0)' })
  async findAll(@Query() { take, skip }) {
    return pagedOutput(await this.usersService.findAll({ take, skip }))
  }
}

It's OK to get parameters in both location: image

mashirozx commented 2 years ago

sorry, post in the wrong repo