-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
This is a meta issue representing a number of requests over the years including #1459 #1840 #892
Currently the OpenAPI specification does not allow optional path parameters nor path parameter values that allow characters such as the /
. This means that if you had the following API description:
/myfiles/{mypath}/{filename}:
parameters:
- name: mypath
type: string
- name: filename
type: string
then you would not be allowed to have myPath = "a/path/to/a/file" unless you escaped the forward slash character.
Also, the RFC6570 URI Template /myreports/{reportName}{/nonDefaultFormat}
where the last path segment is optional is not supported by OAS.
The primary reason for not supporting these types of APIs is that it creates the potential of an ambiguous match between a URL and the corresponding path item. Some tooling depends on being able to identify the API description for a specific URL. If multiple pathItems match, then some kind of alternate selection algorithm must be defined.
There have been a number of suggestions on how that selection algorithm might work, with varying levels of complexity. The open question is if there is enough community demand to justify the work necessary to find an acceptable solution.
If you have real-world scenarios where adding support for either multi-segment path parameters or optional path segments would make your life easier, please share them in this issue.