-
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
Support optional path parameters with default value #622
Comments
Given the planned support for some other aspects of RFC6570, the requirement that path parameters are mandatory may drop altogether. |
That would really awesome :) |
Do you have a time range for when will the next version be public? |
Within a few months. The process itself is public so people can voice their opinions as we progress. |
Parent issue #574 |
@amarzavery As noted on the original Autorest issue, 6570 optional path parameters wouldn't quite meet the needs of the original example. |
and yet 3 1/2 years later, they still appear to be mandatory |
I think @webron used the word "may" because it's not for sure changing... |
i have seen lots of discussions about path parameters containing slashes but nothing on this issue regarding simple path parameters. from what i've read so far, OAS is designed to be how one SHOULD describe an API, not meant to support how APIs have actually been implemented. if that is indeed accurate, then why SHOULD path parameters be mandatory? |
Quite simply, making path parameters optional changes the path semantics and can make resolution of the operation non-deterministic. I know we can all think of one-off use cases where one can justify why it makes sense that |
@fehguy I disagree with your non-determinism comment. I argue that path resolution is non-deterministic by default. For example:
Is deterministic because it always processes the same logic to reliably retrieve the latest blog post. It's also non-deterministic because there's no guarantee that between calls the same blog post will be retrieved.
Are deterministic because they always return the exact same post respectively. However, you're nuts if you think I'm going to specify a path for every post that exists (extreme example) <- and revise my spec every time a new blog post is created. OAS is a specification for describing an API. It is not an example or reference for how an API should be implemented nor does it have anything to do with how path resolution is implemented. I implement my API and I wish to document it. I wish to document it in a standard way to that doc generation tools can deterministically (reliably) generate the docs accurately. I have optional path (route) parameters. I cannot trust that any doc generator will correctly generate a doc for my API because if the generator is OAS-compliant, it MAY ignore or throw an error when it encounters This is an unreasonable restriction. EDIT: (forgot to finish my thought) |
Jumping in here late to say that I also wish for this to be implemented. My use case is the same as @bryan5989 above, in that I have paths:
and I also have
My server receives requests at the root
So a POST request to This is how my application is structured and I would like for it to be documented properly. The reason I would like to be able to document this properly is so that my generated API requests are properly formatted. Right now, when using swagger-ui to connect using my given swagger.json, requests without filling in the optional path parameter look like this:
|
2 years later, I've realized that I misused the term resource in my final thought above. That said, I restate my point that an OAS pathspec does not determine whether you'll get a resource or something else (not a resource) at that path. That's for I the implementer to decide. Which is the whole point of documenting an API in the first place and the reason why OAS should allow me to decide whether a path segment is optional or not. Generator implementors can add switches to honor/ignore that preference. |
My API follows a pattern in which resources can be addressed using its ID within the path. All other params are query params. It'd be nice if OpenAPI allowed this pattern, as nearly all REST frameworks do. |
@rossginn |
@rafalkrupinski Also, consider query params that may exist, for example |
@rossginn |
Moonwalk (OAS 4) is currently slated to fully support RFC 6570. Please join the discussions in the Moonwalk repository to help work out the details for this sort of thing! As it will not fit in a 3.x release, I'm closing it out of this repository. |
As of today, Open API spec asserts that a path parameter should always be required. This is a good assertion.
However, we have some services in Azure that have optional path parameters with a default value. There has been an increasing number of requests from service teams to support this.
What do you think about the following assertion?
This provides more flexibility apart from taking care of the current assertion.
For example:
Can this be included in the 3.0 version of the Open API Spec?
The text was updated successfully, but these errors were encountered: