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.

Swagger doesn't allow equivalent rest paths but with different type of parameters

See original GitHub issue

Guys, 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
darrelmillercommented, Feb 17, 2016

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.

0reactions
fehguycommented, Feb 1, 2017

See merged support for allOf, oneOf, etc. This should address your concerns.

Read more comments on GitHub >

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

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