Skip to content

Commit 44a473e

Browse files
authored
Merge branch 'master' into fixes/821
2 parents bb9cba6 + 365e697 commit 44a473e

File tree

1 file changed

+82
-11
lines changed

1 file changed

+82
-11
lines changed

jsonschema-core.xml

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@
11641164
Meta-schema authoring is an advanced usage of JSON Schema, so the design of
11651165
meta-schema features emphasizes flexibility over simplicity.
11661166
</t>
1167-
<section title='The "$schema" Keyword'>
1167+
<section title='The "$schema" Keyword' anchor="keyword-schema">
11681168
<t>
11691169
The "$schema" keyword is both used as a JSON Schema feature set identifier and
11701170
as the identifier of a resource which is itself a JSON Schema, which describes the
@@ -1185,16 +1185,6 @@
11851185
It MUST NOT appear in non-resource root schema objects. If absent from
11861186
the document root schema, the resulting behavior is implementation-defined.
11871187
</t>
1188-
<t>
1189-
If multiple schema resources are present in a single document, then
1190-
schema resources which do not have a "$schema" keyword in their root
1191-
schema object MUST be processed as if "$schema" were present with the
1192-
same value as for the immediately enclosing resource.
1193-
</t>
1194-
<t>
1195-
Embedded schema resources MAY specify different "$schema" values from their
1196-
enclosing resource, as any schema that can be referenced can also be embedded.
1197-
</t>
11981188
<t>
11991189
Values for this property are defined elsewhere in this and other documents,
12001190
and by other parties.
@@ -1850,6 +1840,86 @@
18501840
</section>
18511841
</section>
18521842

1843+
<section title="Compound Documents">
1844+
<t>
1845+
A Compound Schema Document is defined as JSON document (sometimes called a "bundled" schema)
1846+
which has multiple embedded JSON Schema Resources bundled into the same document to
1847+
ease transportation.
1848+
</t>
1849+
<t>
1850+
Each embedded Schema Resource MUST be treated as an individual Schema Resource, following standard
1851+
schema loading and processing requirements, including determining vocabulary support.
1852+
</t>
1853+
<section title="Bundling">
1854+
<t>
1855+
The bundling process for creating a Compound Schema Document is defined as taking
1856+
references (such as "$ref") to an external Schema Resource and embedding the referenced
1857+
Schema Resources within the referring document. Bundling is done in such a way that
1858+
all URIs (used for referencing) in the base document and any referenced/embedded
1859+
documents do not require altering.
1860+
</t>
1861+
<t>
1862+
Each embedded JSON Schema Resource MUST identify itself with an absolute URI using the "$id" keyword,
1863+
and SHOULD make use of the "$schema" keyword to identify the dialect it is using, in the root of the
1864+
schema resource.
1865+
</t>
1866+
<t>
1867+
When the Schema Resource referenced by a by-reference applicator is bundled, the Schema Resource
1868+
MUST be located as a value of a "$defs" object at the containing schema's root.
1869+
The key of the "$defs" for the now embedded Schema Resource MAY be the "$id" of the bundled schema
1870+
or some other form of application defined unique identifer (such as a UUID). This key is not
1871+
intended to be referenced in JSON Schema, but may be used by an application to aid the
1872+
bundling process.
1873+
</t>
1874+
<t>
1875+
Bundled Schema Resource MUST NOT be bundled by replacing the schema object from which it was
1876+
referenced, or by wrapping the Schema Resource in other applicator keywords.
1877+
</t>
1878+
<t>
1879+
In order to produce identical output, references in the containing schema document to the
1880+
previously external Schema Resources MUST NOT be changed, and now resolve to a schema using the
1881+
"$id" of an embedded Schema Resource. Such identical output includes validation evaluation and URIs
1882+
or paths used in resulting annotations or errors.
1883+
</t>
1884+
<t>
1885+
While the bundling process will often be the main method for creating a Compound Schema Document,
1886+
it is also possible and expected that some will be created by hand, potentially without individual
1887+
Schema Resources existing on their own previously.
1888+
</t>
1889+
</section>
1890+
<section title="Differing and Default Dialects">
1891+
<t>
1892+
If multiple schema resources are present in a single document, then
1893+
schema resources which do not have a "$schema" keyword in their root
1894+
schema object MUST be processed as if "$schema" were present with the
1895+
same value as for the immediately enclosing resource.
1896+
</t>
1897+
<t>
1898+
Since any schema that can be referenced can also be embedded, embedded schema resources MAY
1899+
specify different "$schema" values from their enclosing resource.
1900+
</t>
1901+
</section>
1902+
<section title="Validating">
1903+
<t>
1904+
Given that a Compound Schema Document may have embedded resources which identify as using different
1905+
dialects, these documents SHOULD NOT be validated by applying a meta-schema
1906+
to the Compound Schema Document as an instance. It is RECOMMENDED that an alternate
1907+
validation process be provided in order to validate Schema Documents. Each Schema Resource
1908+
SHOULD be separately validated against its associated meta-schema.
1909+
<cref>
1910+
If you know a schema is what's being validated, you can identify if the schemas
1911+
is a Compound Schema Document or not, by way of use of "$id", which identifies an
1912+
embedded resource when used not at the document's root.
1913+
</cref>
1914+
</t>
1915+
<t>
1916+
A Compound Schema Document in which all embedded resources idenfity as using the same
1917+
dialec, or in which "$schema" is omitted and therefore defaults to that of the enclosing resource,
1918+
MAY be validated by applying the appropriate meta-schema.
1919+
</t>
1920+
</section>
1921+
</section>
1922+
18531923
<section title="Caveats">
18541924
<section title="Guarding Against Infinite Recursion">
18551925
<t>
@@ -3860,6 +3930,7 @@ https://example.com/schemas/common#/$defs/count/minimum
38603930
<t>$dynamicAnchor defines a fragment like $anchor</t>
38613931
<t>$dynamic* (previously $recursive) no longer use runtime base URI determination</t>
38623932
<t>Reference ecma262 11th edition for regular expression support</t>
3933+
<t>Define Compound Schema Documents (bundle) and processing</t>
38633934
<t></t>
38643935
<t></t>
38653936
<t></t>

0 commit comments

Comments
 (0)