Swagger doesn't allow equivalent rest paths but with different type of parameters
See original GitHub issueGuys, I am using node with express for build my api. It gives pretty feature for create the same path with different parameter types:
app.get('/:id(\\d+)/', function (req, res) {
// req.params.id is now defined here for you
});
app.get('/:ordinal(previous | last)/', function (req, res){
// req.params.ordinal should be 'previous' or 'last'
});
Unfortunately, swagger doesn’t allow use this pretty feature and crashes with error:
API path (or equivalent) already defined
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Describing Parameters - Swagger
To describe a parameter, you specify its name , location ( in ), data type (defined by either schema or content ) and...
Read more >Swagger: "equivalent path already exists" despite different ...
That's because the two paths can be identical. I understand that the parameters may uniquely identify them, but OpenAPI 2.0 (Swagger 2.0), ...
Read more >Minimal APIs quick reference - Microsoft Learn
When a request is made a route with parameters declared to capture, the parameters are parsed and passed to the handler. This makes...
Read more >T217881 Decide whether to keep violating OpenAPI/Swagger ...
Specifically, while the Swagger specification for either version 2.x or 3.x does not allow to have optional path parameters, our specs used a...
Read more >Using OpenAPI and Swagger UI - Quarkus
Architecture. In this guide, we create a straightforward REST application to demonstrate how fast you can expose your API specification and benefit from...
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
There are plenty of these scenarios that don’t even have an ugly option in OpenAPI. e.g.
/restaurantsNear?postalCode={postalCode}
/restaurantsNear?lat={lat}&long={long}
The only way to do this with OpenAPI is
/restaurantsNear{?lat,long,postalCode}
The is problematic because there is no way of expressing that the query parameters must be either PostalCode or Lat and Long. All parameters have to be described as optional which is not accurate.
See merged support for
allOf
,oneOf
, etc. This should address your concerns.