Skip to content

Format json-pointer: uri fragment, json pointer or both #328

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

Closed
CroniD opened this issue Jun 7, 2017 · 9 comments
Closed

Format json-pointer: uri fragment, json pointer or both #328

CroniD opened this issue Jun 7, 2017 · 9 comments
Labels
clarification Items that need to be clarified in the specification
Milestone

Comments

@CroniD
Copy link

CroniD commented Jun 7, 2017

Hi there,

first: great work with draft-06. I really like it and I'm about to update my schemes for it. Looks really good so far.

But one thing is unclear to me:

8.3.9. json-pointer

This attribute applies to string instances.

A string instance is valid against this attribute if it is a valid
JSON Pointer, according to [RFC6901]

This means the "json pointer" representation or the uri fragment one, or both? Some validators like ajv (@epoberezkin) allow both versions, but the term "valid JSON pointer" may suggest otherwise. I guess most people will expect both representations to work, but as it is written above it may not be intended (strictly speaking)?
Implementationwise it should be a difference, because an uri fragment may contain percent-encoded characters, while the other one doesn't.

Best regards

@handrews
Copy link
Contributor

handrews commented Jun 7, 2017

My intention with that format was an actual JSON Pointer ("/some/property"), and not a fragment that happens to be a JSON Pointer ("#/some/property"). The fragment would be format uri-reference.

Since RFC 6901 describes the fragment encoding as well, I can see how this would be confusing.

@epoberezkin
Copy link
Member

@handrews uri-reference is wider than fragment that is JSON pointer. Maybe there should be two formats for JSON pointer instead of one...

@handrews
Copy link
Contributor

handrews commented Jun 7, 2017

@epoberezkin I don't see any need for formats for specific fragment-only URI reference syntaxes. Or any other subset of uri-reference. If you really want to ensure that a URI reference is a fragment, then use:

{
    "type": "string",
    "format": "uri-reference",
    "pattern": "^#"
}

Since fragments are interpreted based on the media type of the resourced being referenced, whether or not that fragment can be (or must be) a JSON Pointer is determined by the media type. In the case where a media type (such as application/schema+json) supports multiple fragment resolutions, then you can use a more specific pattern to ensure only JSON Pointer. For instance, the following is sufficient for fragments referencing JSON schemas:

{
    "type": "string",
    "format": "uri-reference",
    "pattern": "^#/"
}

(note the extra forward slash in the pattern)

@CroniD
Copy link
Author

CroniD commented Jun 8, 2017

Thx for your replies.

Do you think it's worth to put a little note to 8.3.9. stating that the fragment representation is excluded?

OR

RFC6901 doesn't use the term "valid Json Pointer". Maybe use "JSON String representation" instead (be close to RFC6901 as possible)?

Are new tests needed to check that (I can write some)? As I can see there are some tests for the json-pointer format.

Best regards

@handrews
Copy link
Contributor

handrews commented Jun 8, 2017

@CroniD yes I think some clarification is in order, leave this issue open and either submit a PR or I'll get around to it eventually (I'm catching up from vacation and also have a cold so I'm not doing much this week).

I'm sure @Julian would welcome PRs on the test suite if there is a gap.

@Julian
Copy link
Member

Julian commented Jun 8, 2017

He would!

@CroniD
Copy link
Author

CroniD commented Jun 9, 2017

Hi all,

tests are written.

@handrews I'm not very good at writing a specification, therefore I'll leave this matter to another one. Best wishes, I hope you will get better soon.

Thank you all. :)

Edit: Please see also the discussion in json-schema-org/JSON-Schema-Test-Suite#186

@handrews
Copy link
Contributor

Further evidence that this requires clarification in the standard (and probably more on the web site, but at least a line about it in the spec seems necessary).

https://groups.google.com/d/msg/json-schema/gP6T8dEVJFQ/Ek3yhbAlBAAJ

@handrews handrews added this to the draft-07 (wright-*-02) milestone Aug 18, 2017
handrews added a commit to handrews/json-schema-spec that referenced this issue Aug 20, 2017
Addresses issue json-schema-org#328.  URI fragment-encoded JSON Pointers are
already handled by the "uri-reference" format, plus "pattern"
if the media type supports multiple fragment types that would
need to be disambiguated.

Guidance on using "uri-reference" plus "pattern" belongs on
the web site, so I did not add it to the spec.
@handrews
Copy link
Contributor

Fixed in #354.

@gregsdennis gregsdennis moved this from Closed to Merged in Proposal: `format` update Jul 17, 2024
@gregsdennis gregsdennis added clarification Items that need to be clarified in the specification and removed Type: Maintenance labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Items that need to be clarified in the specification
Projects
Development

No branches or pull requests

5 participants