From d25ac0e90261b8e09509a7df5539bdca01bc084d Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 8 May 2020 20:47:54 -0700 Subject: [PATCH 1/4] Embedded vs referenced resources behave the same --- jsonschema-core.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index b3ab1da1..f1cf898c 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -450,6 +450,10 @@ is its top-level schema object, which would also be a document root schema if the resource were to be extracted to a standalone JSON Schema document. + + Whether multiple schema resources are embedded or linked with a reference, + they are processed in the same way, with the same available behaviors. + From f1a9a63481b9a291bf304389b2559ab75d5acf4f Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 8 May 2020 19:58:04 -0700 Subject: [PATCH 2/4] 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. --- jsonschema-core.xml | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index f1cf898c..686d9bfd 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -635,7 +635,7 @@ Note that some keywords, such as "$schema", apply to the lexical - scope of the entire schema document, and therefore MUST only + scope of the entire schema resource, and therefore MUST only appear in a schema resource's root schema. @@ -1167,37 +1167,19 @@ media type "application/schema+json". - The "$schema" keyword SHOULD be used in a resource root schema. - It MUST NOT appear in resource subschemas. If absent from the root schema, the - resulting behavior is implementation-defined. + The "$schema" keyword SHOULD be used in the document root schema object, + and MAY be used in the root schema objects of embedded schema resources. + It MUST NOT appear in subschemas. If absent from the document root schema, + the resulting behavior is implementation-defined. - If multiple schema resources are present in a single document, then all - schema resources SHOULD Have the same value for "$schema". The result of - differing values for "$schema" within the same schema document is - implementation-defined. - - Using multiple "$schema" keywords in the same document would imply that the - feature set and therefore behavior can change within a document. This would - necessitate resolving a number of implementation concerns that have not yet - been clearly defined. So, while the pattern of using "$schema" only in root - schemas is likely to remain the best practice for schema authoring, - implementation behavior is subject to be revised or liberalized in - future drafts. - - - The exception made for embedded schema resources is to - allow bundling multiple schema resources into a single schema document - without needing to change their contents, as described later in this - specification. - - + If multiple schema resources are present in a single document, then + schema resources which do not have a "$schema" keyword in their root + schema object inherit the meta-schema from the enclosing resource. + + + Embedded schema resources MAY specify different "$schema" values from their + enclosing resource, as any schema that can be referenced can also be embedded. Values for this property are defined elsewhere in this and other documents, @@ -3803,7 +3785,7 @@ https://example.com/schemas/common#/$defs/count/minimum - + "$schema" MAY change for embedded resources From cafdf71d53dc5fe8e445cadd5e88090f0fcd270a Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 20 May 2020 16:49:23 -0700 Subject: [PATCH 3/4] Formalize $schema inheritance/cascade/whatever --- jsonschema-core.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 686d9bfd..3cd6c968 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1175,7 +1175,8 @@ If multiple schema resources are present in a single document, then schema resources which do not have a "$schema" keyword in their root - schema object inherit the meta-schema from the enclosing resource. + schema object MUST be processed as if "$schema" were present with the + same value as for the immediately enclosing resource. Embedded schema resources MAY specify different "$schema" values from their From 56288b401596c273f77e089957161f07369e9ae9 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Thu, 21 May 2020 23:45:27 -0700 Subject: [PATCH 4/4] Clarify subschema language re: $schema --- jsonschema-core.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 3cd6c968..85ad83c8 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1169,8 +1169,8 @@ The "$schema" keyword SHOULD be used in the document root schema object, and MAY be used in the root schema objects of embedded schema resources. - It MUST NOT appear in subschemas. If absent from the document root schema, - the resulting behavior is implementation-defined. + It MUST NOT appear in non-resource root schema objects. If absent from + the document root schema, the resulting behavior is implementation-defined. If multiple schema resources are present in a single document, then