Swagger: Optional query parameters are not sent by swagger.

Created on 12 Jul 2019  路  2Comments  路  Source: nestjs/swagger

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior


I have a route with two optional parameters, limit and page;

  @Get()
  @ApiImplicitParam({ name: 'page', required: false})
  @ApiImplicitParam({ name: 'limit', required: false})
  async index(
    @Query('page') page: number = 1,
    @Query('limit') limit: number = 10,
  ) {
    limit = limit > 100 ? 100 : limit;
   // implementation
  }

In swagger when I try to run the request, none of my parameters are sent;

When I remove the @ApiImplicitParam decorator for both of the parameters they become required but are sent via swagger.

Expected behavior


Swagger to sent the optional parameters when they are defined.

Environment


[System Information]
OS Version : Windows 7
NodeJS Version : v10.15.0
NPM Version : 6.4.1

For Tooling issues:
platform-express version : 6.5.2
passport version : 6.1.0
swagger version : 3.0.2
typeorm version : 6.1.2
common version : 6.5.2
core version : 6.5.2
jwt version : 6.1.1

Most helpful comment

Use @ApiImplicitQuery() instead of @ApiImplicitParam()

All 2 comments

Use @ApiImplicitQuery() instead of @ApiImplicitParam()

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

malbertSC picture malbertSC  路  5Comments

vh13294 picture vh13294  路  4Comments

mogusbi picture mogusbi  路  3Comments

leefordjudes picture leefordjudes  路  4Comments

itslenny picture itslenny  路  3Comments