-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swagger doesn't allow equivalent rest paths but with different type of parameters #549
Comments
In a way, you can express this with OpenAPI. The parameter itself would be a string and you can use a regex to specify the options. Ugly, but doable. |
There are plenty of these scenarios that don't even have an ugly option in OpenAPI. e.g.
The only way to do this with OpenAPI is
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. |
FWIW, I have a fork of swagger-ui, that supports RFC-6570. So, Its definitely possible to incorporate RFC-6750 support with a little effort. Here is an example of the petstore with templated paths. Granted that swagger-ui isn't the only spec client, and there are some edge-cases (non-standard or language/stack specific accommodations e.g. matrix parameters or array parameters), but I'd definitely like to see #291 incorporated into the spec. |
Parent: #574 |
We also were using this with the Swagger 1.2 specification to provide explicit semantics around access to resources using the following query patterns:
The inability to express these semantics after Swagger 1.2 in the generated API client results in a great loss of clarity. Now callers will have to know out-of-band what properties to supply for the natural key of a particular resource, and they will always be getting back an array -- implying there could be multiple results when in fact they really should either get a single result or a 404 response. |
@gmcelhanon - that wasn't legal in 1.2 either. The tools may puke less by it, but it's not officially supported. |
Just went back and looked at the 1.2 spec again and noticed this line in 5.2.3:
Breaking this never caused us any trouble with SwaggerUI or the SDK code generation, and it met our needs for more precise semantics around the use of natural keys perfectly. Our world isn't ruled by surrogate ids that we define, and retrieving a resource using the natural key values is a distinctly different "operation" than querying it with general query string parameters. |
Right, and this may change in the next version. FYI, we changed the structure of the spec in 2.0 to make it more difficult to 'break' such as your experience. While the spec didn't allow it, it was easier to write something that was invalid. |
See merged support for |
Guys, I am using node with express for build my api. It gives pretty feature for create the same path with different parameter types:
Unfortunately, swagger doesn't allow use this pretty feature and crashes with error:
API path (or equivalent) already defined
The text was updated successfully, but these errors were encountered: