json-schema-spec icon indicating copy to clipboard operation
json-schema-spec copied to clipboard

clarification needed: bundled metaschemas

Open karenetheridge opened this issue 4 years ago • 3 comments

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",
  ...,
}

karenetheridge avatar Sep 30 '21 23:09 karenetheridge

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.

jdesrosiers avatar Oct 01 '21 00:10 jdesrosiers

@Relequestual can you tag this with something like "PR needed", and assign me? cheers!

karenetheridge avatar Oct 09 '21 21:10 karenetheridge

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.

handrews avatar Jun 20 '22 14:06 handrews