Skip to content

Commit 0cce8aa

Browse files
authored
Merge pull request #617 from handrews/dep-schema
Name the split "dependencies" to "dependent*"
2 parents 8e278be + 6788c2e commit 0cce8aa

File tree

4 files changed

+46
-30
lines changed

4 files changed

+46
-30
lines changed

hyper-schema.json

+2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"properties": {
1717
"additionalItems": { "$ref": "#" },
1818
"additionalProperties": { "$ref": "#"},
19+
"dependentSchemas": { "$ref": "#" },
1920
"dependencies": {
21+
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
2022
"additionalProperties": {
2123
"anyOf": [
2224
{ "$ref": "#" },

jsonschema-core.xml

+24-24
Original file line numberDiff line numberDiff line change
@@ -1411,18 +1411,18 @@
14111411

14121412
<section title="Keywords for Applying Subschemas Conditionally" anchor="conditional">
14131413
<t>
1414-
These keywords work together to implement conditional
1415-
application of a subschema based on the outcome of
1416-
another subschema.
1414+
Three of these keywords work together to implement conditional
1415+
application of a subschema based on the outcome of another subschema.
1416+
The fourth is a shortcut for a specific conditional case.
14171417
</t>
14181418
<t>
1419-
These keywords MUST NOT interact with each other across
1419+
"if", "then", and "else" MUST NOT interact with each other across
14201420
subschema boundaries. In other words, an "if" in one
14211421
branch of an "allOf" MUST NOT have an impact on a "then"
14221422
or "else" in another branch.
14231423
</t>
14241424
<t>
1425-
There is no default behavior for any of these keywords
1425+
There is no default behavior for "if", "then", or "else"
14261426
when they are not present. In particular, they MUST NOT
14271427
be treated as if present with an empty schema, and when
14281428
"if" is not present, both "then" and "else" MUST be
@@ -1493,6 +1493,24 @@
14931493
or annotation collection purposes, in such cases.
14941494
</t>
14951495
</section>
1496+
<section title="dependentSchemas">
1497+
<t>
1498+
This keyword specifies subschemas that are evaluated if the instance
1499+
is an object and contains a certain property.
1500+
</t>
1501+
<t>
1502+
This keyword's value MUST be an object.
1503+
Each value in the object MUST be a valid JSON Schema.
1504+
</t>
1505+
<t>
1506+
If the object key is a property in the instance, the entire
1507+
instance must validate against the susbschema. Its use is
1508+
dependent on the presence of the property.
1509+
</t>
1510+
<t>
1511+
Omitting this keyword has the same behavior as an empty object.
1512+
</t>
1513+
</section>
14961514
</section>
14971515
</section>
14981516
<section title="Keywords for Applying Subschemas to Child Instances">
@@ -1690,24 +1708,6 @@
16901708
Omitting this keyword has the same behavior as an empty schema.
16911709
</t>
16921710
</section>
1693-
1694-
<section title="dependencies">
1695-
<t>
1696-
This keyword specifies subschemas that are evaluated if the instance
1697-
is an object and contains a certain property.
1698-
</t>
1699-
<t>
1700-
This keyword's value MUST be an object.
1701-
Each value in the object MUST be a valid JSON Schema.
1702-
</t>
1703-
<t>
1704-
If the object key is a property in the instance, the entire
1705-
instance must validate against the dependency value.
1706-
</t>
1707-
<t>
1708-
Omitting this keyword has the same behavior as an empty object.
1709-
</t>
1710-
</section>
17111711
</section>
17121712
</section>
17131713
</section>
@@ -2048,7 +2048,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
20482048
<list style="symbols">
20492049
<t>Moved "definitions" from the Validation specification here as "$defs"</t>
20502050
<t>Moved applicator keywords from the Validation specification as their own vocabulary</t>
2051-
<t>Moved "dependencies" from the Validation specification, but only the schema form</t>
2051+
<t>Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas"</t>
20522052
</list>
20532053
</t>
20542054
<t hangText="draft-handrews-json-schema-01">

jsonschema-validation.xml

+7-6
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,16 @@
465465
</t>
466466
</section>
467467

468-
<section title="requiredDependencies">
468+
<section title="dependentRequired">
469469
<t>
470470
The value of this keyword MUST be an object. Properties in
471471
this object, if any, MUST be arrays. Elements in each array,
472472
if any, MUST be strings, and MUST be unique.
473473
</t>
474474
<t>
475475
This keyword specifies properties that are required if a specific
476-
other property is present.
476+
other property is present. Their requirement is dependent on the
477+
presence of the other property.
477478
</t>
478479
<t>
479480
Validation succeeds if, for each name that appears in both
@@ -1075,13 +1076,13 @@
10751076
<t hangText='"dependencies"'>
10761077
This keyword had two different modes of behavior, which made it
10771078
relatively challenging to implement and reason about.
1078-
The schema form has been moved to Core under the original
1079-
"dependencies" keyword, as part of the applicator vocabulary.
1079+
The schema form has been moved to Core and renamed to
1080+
"dependentSchemas", as part of the applicator vocabulary.
10801081
It is analogous to "properties", except that instead of applying
10811082
its subschema to the property value, it applies it to the object
10821083
containing the property.
10831084
The property name array form is retained here and renamed to
1084-
"requiredDependencies", as it is an assertion which is a shortcut
1085+
"dependentRequired", as it is an assertion which is a shortcut
10851086
for the conditional use of the "required" assertion keyword.
10861087
</t>
10871088
</list>
@@ -1123,7 +1124,7 @@
11231124
<list style="symbols">
11241125
<t>Moved "definitions" to the core spec as "$defs"</t>
11251126
<t>Moved applicator keywords to the core spec</t>
1126-
<t>Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec</t>
1127+
<t>Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec</t>
11271128
</list>
11281129
</t>
11291130
<t hangText="draft-handrews-json-schema-validation-01">

schema.json

+13
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,20 @@
130130
"propertyNames": { "format": "regex" },
131131
"default": {}
132132
},
133+
"dependentSchemas": {
134+
"type": "object",
135+
"additionalProperties": {
136+
"$ref": "#"
137+
}
138+
},
139+
"dependentRequired": {
140+
"type": "object",
141+
"additionalProperties": {
142+
"$ref": "#/$defs/stringArray"
143+
}
144+
},
133145
"dependencies": {
146+
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
134147
"type": "object",
135148
"additionalProperties": {
136149
"anyOf": [

0 commit comments

Comments
 (0)