-
Notifications
You must be signed in to change notification settings - Fork 64
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
Relative paths? #116
Comments
JSON References do not have any literature about resolution of relative paths relative to where the current reference is defined. So while I understand that you want to be able to use some representation that allows you to reference something relative to the current reference location, it's not possible because the driving specifications (JSON Pointer and JSON References) do not support it. |
I'm open to ideas but unless it's a part of their specs, I just don't see how best to handle this. |
Ok thanks for your quick reply. I understand and agree about the necessity of following the spec. I'm concerned though that the spec may become very popular (maybe already is?) and without this ability we won't be able to represent things like Redux within a single JSON file. There would be no way to represent a graph within a tree structure, like how symlinks work in filesystems. If you or anyone reading this has any sway within the JSON community, I think it would help a lot of people to get RFC 6901 extended to allow relative paths from the current node. |
OpenAPI/Swagger was the technology that led me to writing this library and it's pretty popular. In OpenAPI/Swagger, JSON References are the way to include other parts of the same document and/or another document: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#referenceObject |
Hi, I'm trying json-refs and it works except I can't get relative paths within the same document to work. Here is the setup within a new empty directory to get an absolute path within the same document:
Which is correct. However, I want to be able to reference nodes locally within the same document with a relative path from the current node like
sibling-node
or./sibling-node
,../parent-node
etc. For example:I feel that the output for
"$ref": "#b"
should be the same as for"$ref": "#/a/b"
because it's a relative path instead of an absolute path. At the very least something like"$ref": "#./b"
or"$ref": "./b"
or"$ref": "b"
should work. I don't see the point of requiring absolute paths starting with/
or#/
.Is there any way to use relative paths from a node within the same document? I'm looking at https://tools.ietf.org/html/rfc6901 but I don't see how to do it. If there is no way to do it with RFC 6901, then I feel that a great opportunity has been lost. Do you know of a way to use relative paths within the same document? Or do I need to use a different package or RFC?
P.S. The goal of this is to be able to use relative paths so I don't have to repeat myself in large JSON files. This would be similar to how relative paths work in Firebase:
https://firebase.google.com/docs/reference/security/database/#location
https://firebase.google.com/docs/reference/security/database/#ruledatasnapshot_methods
Thanks for your help!
The text was updated successfully, but these errors were encountered: