Parameter order in Swagger document doesn't correspond to API
See original GitHub issueI’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:
Swagger result:
=> 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.
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).
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (1 by maintainers)
Top Results From Across the Web
Describing Parameters - Swagger
In OpenAPI, a path parameter is defined using in: path . The parameter name must be the same as specified in the path....
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which ... Each template expression in the path MUST correspond to a path...
Read more >Swagger RESTful API Documentation Specification
In the Swagger specification, the data types are used in several locations - Operations, Operation Parameters, Models, and within the data types themselves...
Read more >Using $ref - Swagger
When you document an API, it is common to have some features which you use ... If the string value does not conform...
Read more >Paths and Operations - Swagger
The API client needs to provide appropriate parameter values when making an API ... Operations support some optional elements for documentation purposes:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The same problem exists for
@ApiImplicitParam
decorator. Swagger documentation was generated with inverted order for parameters.My Node.js version: 8.11.3
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.