-
-
Notifications
You must be signed in to change notification settings - Fork 313
Question about $id
#349
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
Comments
@vivin Thank you for catching this! I believe the last sentence you quoted should read:
(emphasized words were added/changed). That would exclude URIs with more than just a fragment, such as You can have an @awwright did we talk about that at some point? I think the case that motivates an explicit clarification here is when someone declares an |
PR #356 is also clarifying this same concept (and a bit more), so I'm going to add the "URI fragment" words in. They fit with other changes to clarify the syntax and usage of exactly this sort of |
There is still the question of what happens if a JSON Pointer fragment is defined that does not match the actual position with respect to the nearest base URI. I'm keeping this issue open for that topic, as it is too unclear to add to the existing PR. |
This addresses the trivial portion of issue json-schema-org#349.
Adding my own confusion to this. From [http://json-schema.org/latest/json-schema-core.html#rfc.section.9.2](Section 9.2 of the core spec):
It also says
I read that to mean that only the root schema could have an absolute URI, that all I think that is consistent with https://github.com/json-schema/json-schema/wiki/The-%22id%22-conundrum, but it's inconsistent with some of the tests in the v6 test suite. In particular, this case:
would require you to resolve both the Is this supposed to be legal in v6? |
@toddobryan Since a fragment is always ignored when considering base URIs, declaring a plain name fragment with I don't recommend paying attention to anything in the old repository. There's a reason it has a big "this is out of date" heading at the top of every wiki page. It's there to be available for historical research only. The full URI for the |
Please clarify this in the spec. In particular, " |
@toddobryan Looking at
the problem appears to be the phrase "object as a whole". If that were replaced with something like:
would you find that sufficiently clear? |
Yes. That would help a lot. Also, please explicitly state that non-fragment URIs are allowed for subschemas. Specifically calling out that authors can use fragments on subschemas without specifically stating that non-fragment Also, just to make sure I've got this--there is nothing to stop me from declaring a new absolute URI in a subschema, correct?
So, in this case, the only way to reference the stuff inside baz through its containing schema is by either using its full URI or by using a fragment with a JSON Pointer? And similarly, to escape from the BTW, according to the proposed core spec, you can't declare fragment
I gather this was to make clear whether a Actually, this brings up something. I guess that a JSON Pointer fragment is also resolved according to the closest defined
I think I understand you to mean that the Is that all correct? |
@toddobryan I will add some clarifications, but it is not JSON Schema's responsibility to repeat RFC 3986's information. When we say something is a URI Reference per RFC 3986 as a normative reference, the expectation is that the reader will refer to the definition there. We do not repeat all of the different variations on URI references. The fragment syntax is examined in detail because fragments are media-type specific. Likewise for defining what parts of the media type's content change the base URI. But everything else is per RFC 3986, and repeating it in the spec is just clutter. The specification is just that: a specification defining the requirements for conforming implementations. It is not a schema author's guide or user's guide. Those belong on the website, and you can request a guide by filing an issue at https://github.com/json-schema-org/json-schema-org.github.io (and we would really love to have more people writing guide articles). I believe that all of your examples are correct, although forbidding slashes is just establishing the plain name fragment syntax, as it behaves differently from the JSON Pointer fragment syntax. PR #356 clarifies the distinctions between plain name and JSON Pointer fragments and their usage. You can still declare an |
@toddobryan BTW the use case for absolute URI |
OK. Now that I know what it says, the sentence is perfectly understandable. Thanks! (My confusion resulted from the fact that I thought each document could only have one base URI. I now realize that every |
@toddobryan LOL, thanks! |
I've added more wording tweaks to #372 to make all of this more clear. |
@handrews @toddobryan this discussion really cleared some things up. Just to clarify, I want to make sure that my understanding is correct. Assuming that the value of
Is that correct? Also, would we get the same resolved ids if the id in the parent scope was Thanks again! |
@vivin all of your bullet point examples are absolutely correct!
If your parent scope is Handling leading / trailing slashes in the base URI and URI reference is covered in detail in RFC 3986, so you can get a full explanation in the examples there. |
@handrews Thank you -- this really helped clear things up for me! |
@vivin I've filed a web site issue to put more explanations on the web site. Since you seem to be happy with the answers and we can track adding things to the web site in the other issue, I'm going to go ahead and close this. |
Perhaps this has been covered elsewhere, but I couldn't find it. I found the definition for
$id
at http://json-schema.org/latest/json-schema-core.html#rfc.section.9.2 a bit confusing; specifically this part:The example that is provided is:
The specification says that
$id
is a URI reference consisting only of a fragment, which I assume is anything starting with a#
. It then goes on to say that the effect of defining an$id
that doesn't match the above requirements, or is not a valid JSON pointer, is not defined.Doesn't that mean that
other.json
andt/inner.json
don't meet this criteria? Neither of those are fragments. Also, what does it mean when the fragment can be a JSON pointer? Can you have an id like#foo/bar/baz
?The text was updated successfully, but these errors were encountered: