diff --git a/hyper-schema.json b/hyper-schema.json index 82cf32fa..b25a2a95 100644 --- a/hyper-schema.json +++ b/hyper-schema.json @@ -16,7 +16,9 @@ "properties": { "additionalItems": { "$ref": "#" }, "additionalProperties": { "$ref": "#"}, + "dependentSchemas": { "$ref": "#" }, "dependencies": { + "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"", "additionalProperties": { "anyOf": [ { "$ref": "#" }, diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 893af5ae..22aa766d 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1099,18 +1099,18 @@
- These keywords work together to implement conditional - application of a subschema based on the outcome of - another subschema. + Three of these keywords work together to implement conditional + application of a subschema based on the outcome of another subschema. + The fourth is a shortcut for a specific conditional case. - These keywords MUST NOT interact with each other across + "if", "then", and "else" MUST NOT interact with each other across subschema boundaries. In other words, an "if" in one branch of an "allOf" MUST NOT have an impact on a "then" or "else" in another branch. - There is no default behavior for any of these keywords + There is no default behavior for "if", "then", or "else" when they are not present. In particular, they MUST NOT be treated as if present with an empty schema, and when "if" is not present, both "then" and "else" MUST be @@ -1181,6 +1181,24 @@ or annotation collection purposes, in such cases.
+
+ + This keyword specifies subschemas that are evaluated if the instance + is an object and contains a certain property. + + + This keyword's value MUST be an object. + Each value in the object MUST be a valid JSON Schema. + + + If the object key is a property in the instance, the entire + instance must validate against the susbschema. Its use is + dependent on the presence of the property. + + + Omitting this keyword has the same behavior as an empty object. + +
@@ -1327,24 +1345,6 @@ Omitting this keyword has the same behavior as an empty schema.
- -
- - This keyword specifies subschemas that are evaluated if the instance - is an object and contains a certain property. - - - This keyword's value MUST be an object. - Each value in the object MUST be a valid JSON Schema. - - - If the object key is a property in the instance, the entire - instance must validate against the dependency value. - - - Omitting this keyword has the same behavior as an empty object. - -
@@ -1685,7 +1685,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0 Moved "definitions" from the Validation specification here as "$defs" Moved applicator keywords from the Validation specification as their own vocabulary - Moved "dependencies" from the Validation specification, but only the schema form + Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas" diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index d38ae783..1faaa15e 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -464,7 +464,7 @@ -
+
The value of this keyword MUST be an object. Properties in this object, if any, MUST be arrays. Elements in each array, @@ -472,7 +472,8 @@ This keyword specifies properties that are required if a specific - other property is present. + other property is present. Their requirement is dependent on the + presence of the other property. Validation succeeds if, for each name that appears in both @@ -1065,13 +1066,13 @@ This keyword had two different modes of behavior, which made it relatively challenging to implement and reason about. - The schema form has been moved to Core under the original - "dependencies" keyword, as part of the applicator vocabulary. + The schema form has been moved to Core and renamed to + "dependentSchemas", as part of the applicator vocabulary. It is analogous to "properties", except that instead of applying its subschema to the property value, it applies it to the object containing the property. The property name array form is retained here and renamed to - "requiredDependencies", as it is an assertion which is a shortcut + "dependentRequired", as it is an assertion which is a shortcut for the conditional use of the "required" assertion keyword. @@ -1113,7 +1114,7 @@ Moved "definitions" to the core spec as "$defs" Moved applicator keywords to the core spec - Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec + Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec diff --git a/schema.json b/schema.json index 182eefb0..880f0a0f 100644 --- a/schema.json +++ b/schema.json @@ -131,7 +131,20 @@ "propertyNames": { "format": "regex" }, "default": {} }, + "dependentSchemas": { + "type": "object", + "additionalProperties": { + "$ref": "#" + } + }, + "dependentRequired": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/stringArray" + } + }, "dependencies": { + "$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"", "type": "object", "additionalProperties": { "anyOf": [