question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Path templating, multiple segments, and RFC 6570?

See original GitHub issue

I’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:closed
  • Created 9 years ago
  • Reactions:30
  • Comments:39 (11 by maintainers)

github_iconTop GitHub Comments

11reactions
sodiumjoecommented, Jul 20, 2017
1reaction
emattheiscommented, Apr 9, 2016

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 the path 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found