You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, you can put $schema in a resource root object, which means you can have multiple $schema keywords in the same document. Currently we say that schema authors SHOULD only have $schema in the document root, and we say that if multiple resources in the same schema have different $schema values, the meta-schema is undefined. There's a CREF giving some of the backstory.
Before the schema resource concept was introduced, and tied to the updated $id keyword, there was concern about allowing $schema to be dropped into any random schema object.
But now we have two types of schema objects: schema resource root objects, and schema objects within a resource. The document root object is a special case of the schema root object.
Schema resource roots are easily detected ($id means its a schema resource root), and we already do special processing of them. Allowing the $schema to change there makes sense, as we want schema resources to behave the same whether they are linked with $ref (in which case you can definitely change $schema) or not (which is currently undefined).
I think we should go ahead and define this behavior. It also fits in with #849 (clarifying and consolidating the schema loading process), where we will talk about how to load embedded schema resources within a single document.
The text was updated successfully, but these errors were encountered:
It should also be possible (thank you $recursiveRef!) to make this restriction explicit in the metaschema with a rule "if the $id property appears, $schema is allowed; else, $schema is prohibited".
@karenetheridge we've generally avoided enforcing those things in the meta-schemas because they are technically not forbidden. They just have "undefined" behavior.
Due to $recursiveRef and $recursiveAnchor, though, you can write your own strict meta-schema with the same standard vocabularies to enforce whatever makes sense to you.
I agree that this is a gray area, (as opposed to people wanting us to, say, forbid properties unless type is object), and I could be convinced that we should enforce resource roots vs subschemas in the meta-schema. But I'm not yet convinced of that. I kind of want to see what people do in practice with making custom meta-schemas now that we've made that easier and more effective.
Currently, you can put
$schema
in a resource root object, which means you can have multiple$schema
keywords in the same document. Currently we say that schema authors SHOULD only have$schema
in the document root, and we say that if multiple resources in the same schema have different$schema
values, the meta-schema is undefined. There's a CREF giving some of the backstory.Before the schema resource concept was introduced, and tied to the updated
$id
keyword, there was concern about allowing$schema
to be dropped into any random schema object.But now we have two types of schema objects: schema resource root objects, and schema objects within a resource. The document root object is a special case of the schema root object.
Schema resource roots are easily detected (
$id
means its a schema resource root), and we already do special processing of them. Allowing the$schema
to change there makes sense, as we want schema resources to behave the same whether they are linked with$ref
(in which case you can definitely change$schema
) or not (which is currently undefined).I think we should go ahead and define this behavior. It also fits in with #849 (clarifying and consolidating the schema loading process), where we will talk about how to load embedded schema resources within a single document.
The text was updated successfully, but these errors were encountered: