Path templating, multiple segments, and RFC 6570?
See original GitHub issueI’m trying to write swagger docs for APIs like dropbox where the number of path segments isn’t known ahead of time. For example, the path template will look something like:
/api/metadata/{filePath}
And the following urls should all match this path:
/api/metadata/file1.txt
/api/metadata/dir1/file2.txt
/api/metadata/dir1/dir2/file3.txt
If we were using RFC 6570, I’d represent this as:
/api/metadata/{/filePath*}
but the swagger v2 spec doesn’t say if this syntax is acceptable or not.
If it is acceptable/correct, could you please let me know in this item? If it’s not, what is the expected way to model APIs like this with runtime variable URI paths?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:30
- Comments:39 (11 by maintainers)
Top Results From Across the Web
RFC 6570: URI Template
RFC 6570 URI Template March 2012 include Simplified BSD License text as described in ... slash-prefixed path segments, semicolon-prefixed path parameters, ...
Read more >URI Template RFC 6570 - IETF Datatracker
Standards Track [Page 1] RFC 6570 URI Template March 2012 include ... slash-prefixed path segments, semicolon-prefixed path parameters, ...
Read more >Overview of RFC 6570 URI Template
Overview of RFC 6570 URI Template ... Level 3 templates: simple expansion with multiple ... “/” operator: expansion of slash-prefixed path segments.
Read more >URI Templates - Apiary Help
There are several parts of the URI Template specification RFC 6570 that is not supported. These include: Label Expansion; Path Segment Expansion; Path...
Read more >URI Templates | Apiary Help
There are several parts of the URI Template specification RFC 6570 that is not supported. These include: Label Expansion; Path Segment Expansion; Path...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
looks like it won’t be supported in 3.0
Option 3 gets my vote.
I would argue that merging query params into the path template may make the overall specification simpler in light of #574 - the uniqueness of an operation could remain verb + path and satisfy the demands for including more variability if the path template had full RFC 6570 support.
Just to add a real-world use case for unescaped parameters: I maintain an API that represents a virtual filesystem with an endpoint
/resources{+path}
where thepath
variable represents the path of the resource (folder or file) in the virtual filesystem - e.g./path/to/some/folder/
or/path/to/some/file
.