Skip to content

Commit baa2f7e

Browse files
authored
Merge branch 'master' into schema-res
2 parents 56288b4 + 378aae2 commit baa2f7e

File tree

3 files changed

+58
-72
lines changed

3 files changed

+58
-72
lines changed

jsonschema-core.xml

Lines changed: 54 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@
707707
an alternate implementation producing the same behavior is available.
708708
Keywords of this sort SHOULD describe reasonable alternate approaches
709709
when appropriate. This approach is demonstrated by the
710-
"<xref target="additionalItems" format="title"/>" and
710+
"<xref target="items" format="title"/>" and
711711
"<xref target="additionalProperties" format="title"/>" keywords in this
712712
document.
713713
</t>
@@ -935,7 +935,7 @@
935935
{
936936
"title": "Feature list",
937937
"type": "array",
938-
"items": [
938+
"prefixItems": [
939939
{
940940
"title": "Feature A",
941941
"properties": {
@@ -2130,11 +2130,11 @@
21302130
"additionalProperties" and itself
21312131
</t>
21322132
<t>
2133-
"additionalItems", whose behavior is defined in terms of "items"
2133+
"items", whose behavior is defined in terms of "prefixItems"
21342134
</t>
21352135
<t>
21362136
"unevaluatedItems", whose behavior is defined in terms of annotations
2137-
from "items", "additionalItems" and itself
2137+
from "prefixItems", "items", "contains", and itself
21382138
</t>
21392139
</list>
21402140
</t>
@@ -2313,61 +2313,53 @@
23132313
properties and array items, and combining their results.
23142314
</t>
23152315
<section title="Keywords for Applying Subschemas to Arrays">
2316-
<section title="items">
2316+
<section title="prefixItems">
23172317
<t>
2318-
The value of "items" MUST be either a valid JSON Schema or
2319-
an array of valid JSON Schemas.
2318+
The value of "prefixItems" MUST be an array of valid JSON Schemas.
23202319
</t>
23212320
<t>
2322-
If "items" is a schema, validation succeeds if all elements
2323-
in the array successfully validate against that schema.
2324-
</t>
2325-
<t>
2326-
If "items" is an array of schemas, validation succeeds if
2327-
each element of the instance validates against the schema at the
2328-
same position, if any.
2321+
Validation succeeds if each element of the instance validates
2322+
against the schema at the same position, if any. This keyword
2323+
does not constrain the length of the array. If the array is longer
2324+
than this keyword's value, this keyword validates only the
2325+
prefix of matching length.
23292326
</t>
23302327
<t>
23312328
This keyword produces an annotation value which is the largest
23322329
index to which this keyword applied a subschema. The value
23332330
MAY be a boolean true if a subschema was applied to every
2334-
index of the instance, such as when "items" is a schema.
2335-
</t>
2336-
<t>
2337-
Annotation results for "items" keywords from multiple
2338-
schemas applied to the same instance location are combined
2339-
by setting the combined result to true if any of the values
2340-
are true, and otherwise retaining the largest numerical value.
2331+
index of the instance, such as is produced by the "items" keyword.
2332+
This annotation affects the behavior of "items" and "unevaluatedItems".
23412333
</t>
23422334
<t>
23432335
Omitting this keyword has the same assertion behavior as
2344-
an empty schema.
2336+
an empty array.
23452337
</t>
23462338
</section>
23472339

2348-
<section title="additionalItems" anchor="additionalItems">
2340+
<section title="items" anchor="items">
23492341
<t>
2350-
The value of "additionalItems" MUST be a valid JSON Schema.
2342+
The value of "items" MUST be a valid JSON Schema.
23512343
</t>
23522344
<t>
2353-
The behavior of this keyword depends on the presence and
2354-
annotation result of "items" within the same schema object.
2355-
If "items" is present, and its annotation result is a number,
2356-
validation succeeds if every instance element at an index
2357-
greater than that number validates against "additionalItems".
2358-
</t>
2359-
<t>
2360-
Otherwise, if "items" is absent or its annotation result
2361-
is the boolean true, "additionalItems" MUST be ignored.
2345+
This keyword applies its subschema to all instance elements
2346+
at indexes greater than the length of the "prefixItems" array
2347+
in the same schema object, as reported by the annotation result
2348+
of that "prefixItems" keyword. If no such annotation
2349+
result exists, "items" applies its subschema to all instance
2350+
array elements.
2351+
<cref>
2352+
Note that the behavior of "items" without "prefixItems" is
2353+
identical to that of the schema form of "items" in prior drafts.
2354+
When "prefixItems" is present, the behavior of "items" is
2355+
identical to the former "additionalItems" keyword.
2356+
</cref>
23622357
</t>
23632358
<t>
2364-
If the "additionalItems" subschema is applied to any
2359+
If the "items" subschema is applied to any
23652360
positions within the instance array, it produces an
2366-
annotation result of boolean true, analogous to the
2367-
single schema behavior of "items". If any "additionalItems"
2368-
keyword from any subschema applied to the same instance
2369-
location produces an annotation value of true, then
2370-
the combined result from these keywords is also true.
2361+
annotation result of boolean true, indicating that all remaining array
2362+
elements have been evaluated against this keyword's subschema.
23712363
</t>
23722364
<t>
23732365
Omitting this keyword has the same assertion behavior as
@@ -2376,7 +2368,7 @@
23762368
<t>
23772369
Implementations MAY choose to implement or optimize this keyword
23782370
in another way that produces the same effect, such as by directly
2379-
checking for the presence and size of an "items" array.
2371+
checking for the presence and size of a "prefixItems" array.
23802372
Implementations that do not support annotation collection MUST do so.
23812373
</t>
23822374
</section>
@@ -2388,7 +2380,7 @@
23882380
<t>
23892381
The behavior of this keyword depends on the annotation results of
23902382
adjacent keywords that apply to the instance location being validated.
2391-
Specifically, the annotations from "items" and "additionalItems",
2383+
Specifically, the annotations from "prefixItems", "items", and "contains",
23922384
which can come from those keywords when they are adjacent to the
23932385
"unevaluatedItems" keyword. Those two annotations, as well as
23942386
"unevaluatedItems", can also result from any and all adjacent
@@ -2397,33 +2389,25 @@
23972389
defined in this document.
23982390
</t>
23992391
<t>
2400-
If an "items" annotation is present, and its annotation result
2401-
is a number, and no "additionalItems" or "unevaluatedItems"
2402-
annotation is present, then validation succeeds if every instance
2403-
element at an index greater than the "items" annotation validates
2404-
against "unevaluatedItems".
2392+
If no relevant annotations are present, the "unevaluatedItems"
2393+
subschema MUST be applied to all locations in the array.
2394+
If a boolean true value is present from any of the relevant annotations,
2395+
"unevaluatedItems" MUST be ignored. Otherwise, the subschema
2396+
MUST be applied to any index greater than the largest annotation
2397+
value for "prefixItems", which does not appear in any annotation
2398+
value for "contains".
24052399
</t>
24062400
<t>
2407-
Otherwise, if any "items", "additionalItems", or "unevaluatedItems"
2408-
annotations are present with a value of boolean true, then
2409-
"unevaluatedItems" MUST be ignored. However, if none of these
2410-
annotations are present, "unevaluatedItems" MUST be applied to
2411-
all locations in the array.
2412-
</t>
2413-
<t>
2414-
This means that "items", "additionalItems", and all in-place applicators
2415-
MUST be evaluated before this keyword can be evaluated. Authors of
2416-
extension keywords MUST NOT define an in-place applicator that would need
2417-
to be evaluated before this keyword.
2401+
This means that "prefixItems", "items", "contains", and all in-place
2402+
applicators MUST be evaluated before this keyword can be evaluated.
2403+
Authors of extension keywords MUST NOT define an in-place applicator
2404+
that would need to be evaluated before this keyword.
24182405
</t>
24192406
<t>
24202407
If the "unevaluatedItems" subschema is applied to any
24212408
positions within the instance array, it produces an
24222409
annotation result of boolean true, analogous to the
2423-
single schema behavior of "items". If any "unevaluatedItems"
2424-
keyword from any subschema applied to the same instance
2425-
location produces an annotation value of true, then
2426-
the combined result from these keywords is also true.
2410+
behavior of "items".
24272411
</t>
24282412
<t>
24292413
Omitting this keyword has the same assertion behavior as
@@ -2446,6 +2430,12 @@
24462430
array element even after the first match has been found. This
24472431
is to ensure that all possible annotations are collected.
24482432
</t>
2433+
<t>
2434+
This keyword produces an annotation value which is an array of
2435+
the indexes to which this keyword validates successfully when applying
2436+
its subschema, in ascending order. The value MAY be a boolean true if the
2437+
subschema validated successfully when applied to every index of the instance.
2438+
</t>
24492439
</section>
24502440
</section>
24512441

@@ -3787,9 +3777,9 @@ https://example.com/schemas/common#/$defs/count/minimum
37873777
<t hangText="draft-handrews-json-schema-03">
37883778
<list style="symbols">
37893779
<t>"$schema" MAY change for embedded resources</t>
3790-
<t></t>
3791-
<t></t>
3792-
<t></t>
3780+
<t>Array-value "items" functionality is now "prefixItems"</t>
3781+
<t>"items" subsumes the old function of "additionalItems"</t>
3782+
<t>"contains" and "unevaluatedItems" interactions now specified</t>
37933783
<t></t>
37943784
<t></t>
37953785
<t></t>

jsonschema-validation.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@
10231023
JSON Schema's data model.
10241024
</t>
10251025
<t>
1026-
The value of this property SHOULD be ignored if "contentMediaType" is not present.
1026+
The value of this property MUST be a valid JSON schema. It SHOULD be ignored if
1027+
"contentMediaType" is not present.
10271028
</t>
10281029
</section>
10291030

meta/applicator.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88

99
"title": "Applicator vocabulary meta-schema",
1010
"properties": {
11-
"additionalItems": { "$recursiveRef": "#" },
11+
"prefixItems": { "$ref": "#/$defs/schemaArray" },
12+
"items": { "$recursiveRef": "#" },
1213
"unevaluatedItems": { "$recursiveRef": "#" },
13-
"items": {
14-
"anyOf": [
15-
{ "$recursiveRef": "#" },
16-
{ "$ref": "#/$defs/schemaArray" }
17-
]
18-
},
1914
"contains": { "$recursiveRef": "#" },
2015
"additionalProperties": { "$recursiveRef": "#" },
2116
"unevaluatedProperties": { "$recursiveRef": "#" },

0 commit comments

Comments
 (0)