-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
🧹 Clarification: usage of non-canonical identifiers in $schema
#1590
Comments
We've removed the allowance of fragments in My implementation would reject this saying that it doesn't recognize that meta-schema. |
Normalization is discussed in RFC 3986 section 6.2.1 (multiple subsections, so I won't quote them), which discusses URI equivalence. The gist is that normalization covers casing, character encoding, path adjustments, trailing slashes, etc. I didn't see anything about fragments during a brief scan. Normalization is not defined outside of equivalence. I'd say that |
Other interesting gaps:
If this was the |
Pedantically, it can't be identified with a URI that has a fragment (anymore) because we removed fragments from But, yes, this needs to be cleaned up. |
I mean that it can be referred to by more than one uri (each of which could have a fragment), not identified by itself as more than one uri (with the Right now, we can't say "the metaschema can only be referred to (via the Summarizing, I think we should explicitly say this:
|
This one concerns me. Surely a meta-schema needs to trace back to one of the meta-schemas we publish. At the very least, it needs to know under what rules to process the schema... unless you want to bring back a previous discussion we (JSON Schema) have had (somewhere) about the separation between processing semantics and dialect. (I believe that discussion was never resolved, leaving things as-is.)
I would add that it still needs to be at the resource root, not buried somewhere. |
In this case the implementation would have to fall back to a stated default (likely the latest draft that it supports), or accept an out of band value passed in, so we should at the very least give a very strong recommendation to always include the $schema keyword for the sake of interoperability.
Yes absolutely, we would need to clarify the $vocabulary keyword needs to be at the root of the metaschema, rather than somewhere in the middle (not even at a resource root lower down). |
The semantics for non-canonical identifiers is effectively implementation defined. Therefore, I think you can't practically use a non-canonical identifier for However, I don't think that necessarily means we should disallow fragments in {
"$schema": "https://json-schema.org/draft/2020-12",
"$id": "https://json-schema.org/draft/2020-12",
"$vocabulary": {...},
"$ref": "#/$defs/meta-schema",
"$defs": {
"meta-schema": { ... },
"strict": {
"$anchor": "strict",
"$ref": "#/$defs/meta-schema",
"unevaluateProperties": false
}
}
} {
"$schema": "https://json-schema.org/draft/2020-12#strict",
...
} I think this is entirely consistent with the spec today, although I'd be surprise if any implementations supported it. (Mine doesn't. It strips and ignores fragments.) It should work because despite it pointing to a subschema, the implementation should be looking at the root of the schema resource for
|
My thoughts on Karen's list
I don't think this is necessary, although I wouldn't opposed to "SHOULD".
I feel like this is just repeating what we already say about non-canonical URIs, but it might be helpful to add a quick note and a link. However, as I pointed out in the previous comment, this does not disallow all fragments because some use of fragments are canonical.
I believe the intention has always been that |
What is unclear?
Is it legal to use a non-canonical identifier in a
$schema
keyword to refer to a metaschema?e.g. if I have this document:
..and use the embedded metaschema in another document, can I reference it using a non-canonical identifier?
I would think this is foolish, and might break some implementations (if using the
$schema
value directly as a lookup in a list of known metaschemas), but it doesn't seem to be strictly disallowed.edit: I found https://json-schema.org/draft/2020-12/json-schema-core#section-8.1.2-6:
"The "$vocabulary" keyword SHOULD be used in the root schema of any schema document intended for use as a meta-schema. It MUST NOT appear in subschemas."
However, I don't think the $vocabulary keyword is strictly required in a metaschema (or perhaps this is the point that needs clarification?) -- as some metaschemas can be simply a combination of other schemas via an allOf.
Proposal
I can't see a good reason to allow this, so I would recommend making it explictly prohibited.
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
Yes
The text was updated successfully, but these errors were encountered: