swagger: Parameter order in Swagger document doesn't correspond to API

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

Controller method: image

Swagger result:

image

=> configurationName and module is reversed 😕 This has the consequence that e.g. NSwag generated methods also have the wrong parameter order.

Expected behavior

The Swagger doc respects the source-code order.

Bug cause

The problem is that the route parameters decorator metadata (ROUTE_ARGS_METADATA) contains a object, not an array (as DECORATORS.API_PARAMETERS does). => exploreApiReflectedParametersMetadata doesn’t return the correct order.

See the following debugger screenshot.

image

Sorting parameters by the object keys (i.e. 5:0, 5:1 in the shown example) explicitly, using …

const sortedParameters = lodash_1.map(lodash_1.sortBy(lodash_1.map(parameters, (item, name) => ({item, name})), 'name'), x => x.item);

… fixes the issue (see also debugger screenshot).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (1 by maintainers)

Most upvoted comments

The same problem exists for @ApiImplicitParam decorator. Swagger documentation was generated with inverted order for parameters.

My Node.js version: 8.11.3