question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameter order in Swagger document doesn't correspond to API

See original GitHub issue

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).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
adrianpietkacommented, Sep 12, 2018

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

My Node.js version: 8.11.3

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found