json-schema-spec
json-schema-spec copied to clipboard
clarification needed: bundled metaschemas
in https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.1.2:
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.
I'm not sure if the intent here is that metaschemas cannot be bundled which would (assuming that there are "$schema" and "$id" keywords alongside), result in "$vocabulary" appearing in the root of its particular resource but not in the root of the actual document itself -- or if this language preceded the formalization of bundling.
I think this usecase should be explicitly called out as either allowed or disallowed.
example:
{
"$defs": {
"metaschema": {
"$id": "https://localhost:1234/mymetaschema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$vocabulary": {
...
}
}
},
"$id": "https://localhost:1234/myschema",
"$schema": "https://localhost:1234/mymetaschema",
...,
}
Good point. Maybe that should probably say "any schema resource intended for use as a meta-schema". If I understand the terminology used in the spec correctly, the example as a whole is a "Schema Document" (or a Compound Schema Document in this case) which includes two "Schema Resources": .../myschema and .../mymetaschema.
But, a Schema Resource is completely independent of the schema it's embedded in and has all the same capabilities as a Schema Document. So you could argue that if it's allowed for a Schema Document, it should be implicitly allowed for a Schema Resource. It's certainly confusing what that statement means.
@Relequestual can you tag this with something like "PR needed", and assign me? cheers!
or if this language preceded the formalization of bundling
But, a Schema Resource is completely independent of the schema it's embedded in and has all the same capabilities as a Schema Document. So you could argue that if it's allowed for a Schema Document, it should be implicitly allowed for a Schema Resource. It's certainly confusing what that statement means.
I'm 99% certain that this either just pre-dated sorting out the document vs resource concept, or was essentially a typo as it took me a while to really get used to writing the correct term. "Schema resource" makes more sense.