-
-
Notifications
You must be signed in to change notification settings - Fork 309
Simplify the processing of "$vocabulary" #1281
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
Hello, I am trying to make sense about $vocabulary but it does not feel like it is only an annotation. For instance in the test suite, it is expected that vocabulary that is not declared in the metaschema is not applied, even though the given data is not itself a schema (as if we were validating a schema with a meta schema) but mere data. |
@lud-wj we have a backlog item to create docs for vocabs in general. Until we get that on https://json-schema.org, please have a read through my docs on the subject. That should help. The test suite does check that assertion keywords that are defined in unlisted vocabularies are not validated, yes, but that's not considered a meta-schema validation.
Note: since 2020-12 provides annotations for unknown keywords' values, you will get annotations for those. This means that annotation-only keywords behave the same whether their vocabulary is listed or not. |
Thanks @gregsdennis your website is really helpful. I think I get a better understanding of where the "split" is between what capabilities a vocabulary declares and the part that it declares to validate schemas using those new keywords. |
These items need to be incorporated into whatever vocabularies ends up being. Regardless, it's being extracted into the feature life cycle, so it'll need to be worked out there. |
This would not significantly change anything about the behavior of
$vocabulary
. While there are ambiguities in the current wording, I will be filing thoughts on clarifying those as separate issues.Currently,
$vocabulary
requires cumbersome distinctions between schema vs meta-schema processing. This issue plus #1183 would allow removing such distinctions. It is also outside of the existing keyword classifications, despite not needing such special treatment. We can solve this by:$vocabulary
an annotation, which it is$vocabulary
MUST be ignored (but still collected) if it is not from the first dynamic scope (defined as the dynamic scope with empty string as its evaluation path""
)$vocabulary
are only defined when the instance is a JSON Schema, and that any other interpretation MUST NOT be considered interoperable (I'm leaving the possibility open that someone might figure out some other viable interpretation, perhaps with a media type that embeds JSON Schemas, and there's no point in forbidding it because that usage is outside the scope of JSON Schema)$vocabulary
: This was one of the main reasons for the weird description in the first place, which is that we don't want to mandate meta-schema validation as a prerequisite for figuring out the vocabularies. Since the schema object of the first dynamic scope is predictable (it's the object directly referenced by the (meta-)schema's identifier), implementations MAY inspect$vocabulary
statically and consider it to have been applied as an annotation to the instance(-schema) root, and MAY cache this result just as they would have cached the annotation resulting from meta-schema evaluation.Point 4 is the only part of the above that is not already part of the JSON Schema processing model in some way, and it just explains what I'm pretty sure some implementations do already.
While there has been some discussion of removing the restriction in point 2, let's not discuss that here (if anyone feels strongly about it, feel free to file an issue).
This would involve the following changes:
$vocabulary
is an annotation$vocabulary
MUST be ignored for non-schema instances) with point 2 (that only the annotation from the first dynamic scope can be used) and point 3 (that the annotation semantics are only defined for schemas). Most importantly, this removes the phrase documents that are not being processed as a meta-schema so that we can move away from special meta-schema processing. It also removes confusing language that implies that$vocabulary
has any effect on the schema that contains$vocabulary
(because of point 1 about annotations, there should not be any confusion on this point any more)$vocabulary
(for avoiding the cost of meta-schema validation, and/or for implementations that do not support annotation collection)Any objections? The only practical impact is that implementations that collect annotations should now collect
$vocabulary
(from any/all dynamic scopes, the restriction on dynamic scope is only on the usage, not the collection. Since we don't have annotation tests yet, there is no impact on the existing test suite.If no one objects in the next week I'll write a PR for this.
The text was updated successfully, but these errors were encountered: