Skip to content

Commit f58a4ee

Browse files
committed
Different $schema values in embedded resources
$schema is now definitively resource-scoped rather than document-scoped, as crossing a resource boundary is the same as following a $ref to an external resource.
1 parent c36d44c commit f58a4ee

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

jsonschema-core.xml

+17-30
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@
635635
</t>
636636
<t>
637637
Note that some keywords, such as "$schema", apply to the lexical
638-
scope of the entire schema document, and therefore MUST only
638+
scope of the entire schema resource, and therefore MUST only
639639
appear in a schema resource's root schema.
640640
</t>
641641
<t>
@@ -1167,37 +1167,19 @@
11671167
media type "application/schema+json".
11681168
</t>
11691169
<t>
1170-
The "$schema" keyword SHOULD be used in a resource root schema.
1171-
It MUST NOT appear in resource subschemas. If absent from the root schema, the
1172-
resulting behavior is implementation-defined.
1170+
The "$schema" keyword SHOULD be used in the document root schema object,
1171+
and MAY be used in the root schema objects of embedded schema resources.
1172+
It MUST NOT appear in subschemas. If absent from the document root schema,
1173+
the resulting behavior is implementation-defined.
11731174
</t>
11741175
<t>
1175-
If multiple schema resources are present in a single document, then all
1176-
schema resources SHOULD Have the same value for "$schema". The result of
1177-
differing values for "$schema" within the same schema document is
1178-
implementation-defined.
1179-
<cref>
1180-
Using multiple "$schema" keywords in the same document would imply that the
1181-
feature set and therefore behavior can change within a document. This would
1182-
necessitate resolving a number of implementation concerns that have not yet
1183-
been clearly defined. So, while the pattern of using "$schema" only in root
1184-
schemas is likely to remain the best practice for schema authoring,
1185-
implementation behavior is subject to be revised or liberalized in
1186-
future drafts.
1187-
</cref>
1188-
<cref>
1189-
The exception made for embedded schema resources is to
1190-
allow bundling multiple schema resources into a single schema document
1191-
without needing to change their contents, as described later in this
1192-
specification.
1193-
</cref>
1194-
<!--
1195-
In particular, the process of validating an instance, including validating a
1196-
schema as an instance against its meta-schema, only allows for a single set
1197-
of rules across the entire instance document. There is no equivalent of
1198-
changing the meta-schema partway through the validation for non-schema
1199-
instances.
1200-
-->
1176+
If multiple schema resources are present in a single document, then
1177+
schema resources which do not have a "$schema" keyword in their root
1178+
schema object inherit the meta-schema from the enclosing resource.
1179+
</t>
1180+
<t>
1181+
Embedded schema resources MAY specify different "$schema" values from their
1182+
enclosing resource, as any schema that can be referenced can also be embedded.
12011183
</t>
12021184
<t>
12031185
Values for this property are defined elsewhere in this and other documents,
@@ -3769,6 +3751,11 @@ https://example.com/schemas/common#/$defs/count/minimum
37693751
</t>
37703752
<t>
37713753
<list style="hanging">
3754+
<t hangText="draft-handrews-json-schema-03">
3755+
<list style="symbols">
3756+
<t>"$schema" MAY change for embedded resources</t>
3757+
</list>
3758+
</t>
37723759
<t hangText="draft-handrews-json-schema-02">
37733760
<list style="symbols">
37743761
<t>Update to RFC 8259 for JSON specification</t>

0 commit comments

Comments
 (0)