Skip to content

Commit 6788c2e

Browse files
committed
Name the split "dependencies" to "dependent*"
Upon further discussion, the grammatical approach that is most intuitive was deemed to be that the string array or schema's usage is dependent upon the presence or absence of the instance property. In at least some anecdotal reports, the nature and direction of the "dependencies" concept proved confusing. Others found it intuitive. The revised wording aims to explicitly tie the dependency direction to the naming convention. In addition, while there was some debate over the most migration-friendly strategy, the decision is to leave the old form of "dependencies" available as an extension, and for at least one draft use the meta-schema to avoid its redefinition. Therefore both keywords resulting from the split have been renamed. "dependentSchemas" was also in the wrong section. As an in-place conditional applicator, it belongs with "if", "then", and "else". Not with the object child applicators. Apparently, I had not made the meta-schema changes at all. The "$comment" follows the precedent established from leaving "definitions" in the meta-schema after the rename to "$defs".
1 parent 5b51942 commit 6788c2e

File tree

4 files changed

+46
-30
lines changed

4 files changed

+46
-30
lines changed

hyper-schema.json

Lines changed: 2 additions & 0 deletions
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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,18 +1099,18 @@
10991099

11001100
<section title="Keywords for Applying Subschemas Conditionally" anchor="conditional">
11011101
<t>
1102-
These keywords work together to implement conditional
1103-
application of a subschema based on the outcome of
1104-
another subschema.
1102+
Three of these keywords work together to implement conditional
1103+
application of a subschema based on the outcome of another subschema.
1104+
The fourth is a shortcut for a specific conditional case.
11051105
</t>
11061106
<t>
1107-
These keywords MUST NOT interact with each other across
1107+
"if", "then", and "else" MUST NOT interact with each other across
11081108
subschema boundaries. In other words, an "if" in one
11091109
branch of an "allOf" MUST NOT have an impact on a "then"
11101110
or "else" in another branch.
11111111
</t>
11121112
<t>
1113-
There is no default behavior for any of these keywords
1113+
There is no default behavior for "if", "then", or "else"
11141114
when they are not present. In particular, they MUST NOT
11151115
be treated as if present with an empty schema, and when
11161116
"if" is not present, both "then" and "else" MUST be
@@ -1181,6 +1181,24 @@
11811181
or annotation collection purposes, in such cases.
11821182
</t>
11831183
</section>
1184+
<section title="dependentSchemas">
1185+
<t>
1186+
This keyword specifies subschemas that are evaluated if the instance
1187+
is an object and contains a certain property.
1188+
</t>
1189+
<t>
1190+
This keyword's value MUST be an object.
1191+
Each value in the object MUST be a valid JSON Schema.
1192+
</t>
1193+
<t>
1194+
If the object key is a property in the instance, the entire
1195+
instance must validate against the susbschema. Its use is
1196+
dependent on the presence of the property.
1197+
</t>
1198+
<t>
1199+
Omitting this keyword has the same behavior as an empty object.
1200+
</t>
1201+
</section>
11841202
</section>
11851203
</section>
11861204
<section title="Keywords for Applying Subschemas to Child Instances">
@@ -1327,24 +1345,6 @@
13271345
Omitting this keyword has the same behavior as an empty schema.
13281346
</t>
13291347
</section>
1330-
1331-
<section title="dependencies">
1332-
<t>
1333-
This keyword specifies subschemas that are evaluated if the instance
1334-
is an object and contains a certain property.
1335-
</t>
1336-
<t>
1337-
This keyword's value MUST be an object.
1338-
Each value in the object MUST be a valid JSON Schema.
1339-
</t>
1340-
<t>
1341-
If the object key is a property in the instance, the entire
1342-
instance must validate against the dependency value.
1343-
</t>
1344-
<t>
1345-
Omitting this keyword has the same behavior as an empty object.
1346-
</t>
1347-
</section>
13481348
</section>
13491349
</section>
13501350
</section>
@@ -1685,7 +1685,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
16851685
<list style="symbols">
16861686
<t>Moved "definitions" from the Validation specification here as "$defs"</t>
16871687
<t>Moved applicator keywords from the Validation specification as their own vocabulary</t>
1688-
<t>Moved "dependencies" from the Validation specification, but only the schema form</t>
1688+
<t>Moved the schema form of "dependencies" from the Validation specification as "dependentSchemas"</t>
16891689
</list>
16901690
</t>
16911691
<t hangText="draft-handrews-json-schema-01">

jsonschema-validation.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,16 @@
464464
</t>
465465
</section>
466466

467-
<section title="requiredDependencies">
467+
<section title="dependentRequired">
468468
<t>
469469
The value of this keyword MUST be an object. Properties in
470470
this object, if any, MUST be arrays. Elements in each array,
471471
if any, MUST be strings, and MUST be unique.
472472
</t>
473473
<t>
474474
This keyword specifies properties that are required if a specific
475-
other property is present.
475+
other property is present. Their requirement is dependent on the
476+
presence of the other property.
476477
</t>
477478
<t>
478479
Validation succeeds if, for each name that appears in both
@@ -1065,13 +1066,13 @@
10651066
<t hangText='"dependencies"'>
10661067
This keyword had two different modes of behavior, which made it
10671068
relatively challenging to implement and reason about.
1068-
The schema form has been moved to Core under the original
1069-
"dependencies" keyword, as part of the applicator vocabulary.
1069+
The schema form has been moved to Core and renamed to
1070+
"dependentSchemas", as part of the applicator vocabulary.
10701071
It is analogous to "properties", except that instead of applying
10711072
its subschema to the property value, it applies it to the object
10721073
containing the property.
10731074
The property name array form is retained here and renamed to
1074-
"requiredDependencies", as it is an assertion which is a shortcut
1075+
"dependentRequired", as it is an assertion which is a shortcut
10751076
for the conditional use of the "required" assertion keyword.
10761077
</t>
10771078
</list>
@@ -1113,7 +1114,7 @@
11131114
<list style="symbols">
11141115
<t>Moved "definitions" to the core spec as "$defs"</t>
11151116
<t>Moved applicator keywords to the core spec</t>
1116-
<t>Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec</t>
1117+
<t>Renamed the array form of "dependencies" to "dependentRequired", moved the schema form to the core spec</t>
11171118
</list>
11181119
</t>
11191120
<t hangText="draft-handrews-json-schema-validation-01">

schema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,20 @@
131131
"propertyNames": { "format": "regex" },
132132
"default": {}
133133
},
134+
"dependentSchemas": {
135+
"type": "object",
136+
"additionalProperties": {
137+
"$ref": "#"
138+
}
139+
},
140+
"dependentRequired": {
141+
"type": "object",
142+
"additionalProperties": {
143+
"$ref": "#/$defs/stringArray"
144+
}
145+
},
134146
"dependencies": {
147+
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
135148
"type": "object",
136149
"additionalProperties": {
137150
"anyOf": [

0 commit comments

Comments
 (0)