Skip to content

Clarification on path templates that overlap another path #1127

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

Closed
lmsurpre opened this issue May 25, 2017 · 7 comments
Closed

Clarification on path templates that overlap another path #1127

lmsurpre opened this issue May 25, 2017 · 7 comments
Assignees
Milestone

Comments

@lmsurpre
Copy link

Apologies if I'm missing something obvious, but I was trying to find a definitive statement that describes whether/how overlapping paths should work. For example, consider two paths like:

  • /one
  • /{template}

I browsed the spec but didn't see it. I browsed through Issue #574 and related issues, but those seem to cover more advanced cases.

I think its generally understood that this is supported (just look at http://petstore.swagger.io/) and that the concrete/fixed path(s) takes 'precedence' over the path template or path wildcard, but I was just looking for some re-assurance from the spec. Hopefully something I just missed?

@fehguy
Copy link
Contributor

fehguy commented May 25, 2017

It's not supported (I believe) so perhaps the documentation needs updating. If the path mapping is not deterministic, the definition does little good.

@webron ?

@lmsurpre
Copy link
Author

Wow, I'm glad I asked. Unless I'm missing something, the ubiquitous pet store example I mentioned uses this pattern in two different places:

  • /pet/findByStatus
  • /pet/{petId}
  • /user/login
  • /user/logout
  • /user/{username}

This lead me to believe it is probably supported by all the tooling, even if not officially defined in the spec.

@DavidBiesack
Copy link

I hope this will continue to be allowed. It is not prohibited in paths object (or in 2.0 or the existing toos) so adding such a restriction now would be a breaking change. The mapping is deterministic, just as a regular expression (login|logout|.*) is valid (even if redundant). In the above example, this means a username of "login" or "logout" is not allowed. So one must be very careful about such overloading, but I don't think OAS should prohibit it.

@webron
Copy link
Member

webron commented May 25, 2017

@lmsurpre Your initial idea is correct. A concrete path definition will take precedence over a templated path - there could never be ambiguity in path patching, so it's not an issue.

We can clarify the wording in the spec.

@webron webron self-assigned this Jun 1, 2017
@webron
Copy link
Member

webron commented Jun 15, 2017

Clarification merged.

@kinvaris
Copy link

kinvaris commented Aug 28, 2023

It seems that tools to validate OAS, still seems to validate these endpoints, and do not mark them as ambiguous nor wrong.
It seems this does not only need work in the docs. But also in the schema validator.

Example endpoints with same methods:

/api/requests/{id}/{action}  # holds action as enum e.g. confirm-arrival, start-test, accept, ...
/api/requests/{id}/reject      # dedicated api endpoint, but not included in the wildcard api endpoint, because it has other parameters.

@handrews
Copy link
Member

@kinvaris feel free to file an issue on the OAI/oascomply repository for anything you see tools handling strangely that you'd like the (still under development) compliance tool to check.

@handrews handrews added this to the v3.0.0-rc2 milestone Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants