#How can I define addition swagger param but not appear in controller/service

3 messages · Page 1 of 1 (latest)

rich rapids
#

I have common QueryOptionDto like

import { ApiProperty } from '@nestjs/swagger'
import { TransformArray } from '../decorators'

export class QueryOptionDto {
  @ApiProperty({ example: 1 })
  page?: number
  @ApiProperty({ example: 10 })
  limit?: number
  @ApiProperty({ example: ['name:asc'] })
  @TransformArray
  sort?: string[]
}

and I use it in another Dto by extends it

export class GetUserDto extends QueryOptionDto {
  @ApiProperty({ example: 'John'})
  search? : string
}

then I use GetUserDto in controller

class UserController {
  @Get()
  get(@Query query : GetUserDto ) {

  }
}

I dont want params page limit sort appear in controller but still in swagger. How can I achieve this?

rich rapids
#

any idea?

rich rapids
#

found it,

I add

@ApiQuery({ type: QueryOptionDto })
@Get()
  get(@Query query : GetUserDto ) {

  }