-
Notifications
You must be signed in to change notification settings - Fork 4
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
YAML Fragment as alias nodes. #41 #47
Conversation
@cabo WDYT of this text? |
Is there existing prior art using |
@eemeli iiuc JSON Pointers must start with
pinging @mnot for a check |
... or be empty (* is 0 or more). All non-empty JSON pointers indeed start with a The semantics of JSON pointers as defined in Section 4 of RFC 6901 unsurprisingly do not discuss YAML data that are not JSON data. I would simply leave it at that -- JSON pointers can only point to data that is reachable on a path through string-keyed maps and arrays. We use JSON pointers in SDF. Nobody considered this to be an innovation of any kind, so I'd expect the perception that they are widespread as fragment identifiers to be widespread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the general idea; not in a position to deeply consider the exact wording just now, or for the next week or so.
Co-authored-by: cabo <cabo@tzi.org>
About empty fragment identifiersAre they used in the wild is association with yaml (e.g. in OpenAPI?) cc: @dret could you make a brief investigation on that? Since the empty `` fragment identifier in JSON Pointer references the whole document, this seems a reasonable About using JSON-* fragment identifiers with YAML
This needs to be addressed better. Notes@cabo @eemeli do you think there's interest for an extension of JSONPath/JSONPointer to better cover the YAML specifications? Sincerely I don't know how to do it, but since there's some interest in the YAML world for defining pathlike alias nodes, maybe a discussion could be useful. |
On 2022-05-26 12:25, Roberto Polli wrote:
Are they used in the wild is association with yaml (e.g. in OpenAPI?)
cc: @dret <https://github.com/dret> could you make a brief investigation
on that?
not sure i can help here. but we could ask @pautasso about this because
they have a very rich dataset of OpenAPI files that they can probably
use for questions like this.
|
That's exactly what I meant :P Let's wait for feedback. |
Empty fragment identifiers are used in JSON Schema for recursive references. For example, this schema modeling a family tree. type: object,
properties:
name:
type: string
children:
$ref: '#'
required:
- name |
@jdesrosiers in this case it is a "full" JSON Pointer, right? Should it resolve to |
@ioggstream If this schema we part of an OpenAPI document, then yes, the reference would resolve to root of the document. So, in an OpenAPI document, an empty fragment reference never makes sense. You would only do this in a JSON Schema document, which are often written in YAML. In OpenAPI, it would look like this, components:
schemas:
Person:
type: object,
properties:
name:
type: string
children:
$ref: '#/components/Person'
required:
- name |
Both
JSON Schema has done this since the beginning. A fragment that is empty or starts with a '/' is parsed as a JSON Pointer fragment per RFC 6901. Any other fragment is parsed as a plain name fragment, which (as we follow that linked document's recommendations and use the NCName syntax) cannot start with a |
On 9. Jun 2022, at 00:29, Henry Andrews ***@***.***> wrote:
Both "" (the empty string) and "/" (a single forward slash) are normal JSON Pointers and fully usable in fragments the same way as any other JSON Pointer.
Yes. And for those who haven’t read RFC 6901 yet, it may be worth to point out that “/“ points to the member in the root JSON object with the name (map key) “”, see https://www.rfc-editor.org/rfc/rfc6901#page-5 for an example.
Grüße, Carsten
|
Co-authored-by: Darrel <darrmi@microsoft.com>
This PR
Arose from discussing with @cabo and @eemeli and supports different fragment identifiers:
*
/
This mechanism should be easily extensible to jsonpath (which according to the current I-D must start with a
$
).