Support for path parameters which can contain slashes
See original GitHub issueI see there are a few issues which ask for the opposite, e.g. this one https://github.com/swagger-api/swagger-js/pull/280 , but what I’m asking for is to add some option to the parameter, which would allow it to contain non-encoded slashes.
My use case: I have an API which allows any arbitrary path to be passed in, for example all of these:
/api/tags
/api/tags/foo
/api/tags/foo/bar/baz
Are valid paths. I tried to describe it as follows:
/tags{tag_path}:
get:
parameters:
- name: tag_path
in: path
required: true
type: string
default: "/"
However, https://generator.swagger.io encodes slashes in the path, so it doesn’t work. So is there a way to describe my API? It feels to me like a perfectly valid use case, so I’m surprised it’s not supported.
If it’s indeed not supported, then one possible solution is to add some option for the path parameter, which would allow it to contain non-encoded slashes.
What do you think?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:57
- Comments:58 (21 by maintainers)
Top GitHub Comments
It would still be nice to have this feature
Could someone from the OpenAPI core team leave a final comment on the likelihood of this being added to a future spec? The most common cases I see summarized here are:
*
to match a path and any subpath after it :/myapi/tags/animals/mammals/tiger
/myapi/tags/animals/mammals/tiger/tag_properties
The argument against this feature was to be able to automatically match requests against documentation, which of course should be retained. But both (1) and (2) do not need to cause problems, if some simple rules are set up, e.g.
*
at the end of a path is only tried when less-specific paths don’t matchThe rules could even be more strict than that.