Skip to content

Commit b615488

Browse files
authored
Merge pull request #914 from handrews/schema-res
$schema can change across embedded resources
2 parents 378aae2 + baa2f7e commit b615488

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

jsonschema-core.xml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@
450450
is its top-level schema object, which would also be a document root schema
451451
if the resource were to be extracted to a standalone JSON Schema document.
452452
</t>
453+
<t>
454+
Whether multiple schema resources are embedded or linked with a reference,
455+
they are processed in the same way, with the same available behaviors.
456+
</t>
453457
</section>
454458
</section>
455459

@@ -631,7 +635,7 @@
631635
</t>
632636
<t>
633637
Note that some keywords, such as "$schema", apply to the lexical
634-
scope of the entire schema document, and therefore MUST only
638+
scope of the entire schema resource, and therefore MUST only
635639
appear in a schema resource's root schema.
636640
</t>
637641
<t>
@@ -1163,37 +1167,20 @@
11631167
media type "application/schema+json".
11641168
</t>
11651169
<t>
1166-
The "$schema" keyword SHOULD be used in a resource root schema.
1167-
It MUST NOT appear in resource subschemas. If absent from the root schema, the
1168-
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 non-resource root schema objects. If absent from
1173+
the document root schema, the resulting behavior is implementation-defined.
11691174
</t>
11701175
<t>
1171-
If multiple schema resources are present in a single document, then all
1172-
schema resources SHOULD Have the same value for "$schema". The result of
1173-
differing values for "$schema" within the same schema document is
1174-
implementation-defined.
1175-
<cref>
1176-
Using multiple "$schema" keywords in the same document would imply that the
1177-
feature set and therefore behavior can change within a document. This would
1178-
necessitate resolving a number of implementation concerns that have not yet
1179-
been clearly defined. So, while the pattern of using "$schema" only in root
1180-
schemas is likely to remain the best practice for schema authoring,
1181-
implementation behavior is subject to be revised or liberalized in
1182-
future drafts.
1183-
</cref>
1184-
<cref>
1185-
The exception made for embedded schema resources is to
1186-
allow bundling multiple schema resources into a single schema document
1187-
without needing to change their contents, as described later in this
1188-
specification.
1189-
</cref>
1190-
<!--
1191-
In particular, the process of validating an instance, including validating a
1192-
schema as an instance against its meta-schema, only allows for a single set
1193-
of rules across the entire instance document. There is no equivalent of
1194-
changing the meta-schema partway through the validation for non-schema
1195-
instances.
1196-
-->
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 MUST be processed as if "$schema" were present with the
1179+
same value as for the immediately enclosing resource.
1180+
</t>
1181+
<t>
1182+
Embedded schema resources MAY specify different "$schema" values from their
1183+
enclosing resource, as any schema that can be referenced can also be embedded.
11971184
</t>
11981185
<t>
11991186
Values for this property are defined elsewhere in this and other documents,
@@ -3789,7 +3776,7 @@ https://example.com/schemas/common#/$defs/count/minimum
37893776
<list style="hanging">
37903777
<t hangText="draft-handrews-json-schema-03">
37913778
<list style="symbols">
3792-
<t></t>
3779+
<t>"$schema" MAY change for embedded resources</t>
37933780
<t>Array-value "items" functionality is now "prefixItems"</t>
37943781
<t>"items" subsumes the old function of "additionalItems"</t>
37953782
<t>"contains" and "unevaluatedItems" interactions now specified</t>

0 commit comments

Comments
 (0)