|
707 | 707 | an alternate implementation producing the same behavior is available.
|
708 | 708 | Keywords of this sort SHOULD describe reasonable alternate approaches
|
709 | 709 | when appropriate. This approach is demonstrated by the
|
710 |
| - "<xref target="additionalItems" format="title"/>" and |
| 710 | + "<xref target="items" format="title"/>" and |
711 | 711 | "<xref target="additionalProperties" format="title"/>" keywords in this
|
712 | 712 | document.
|
713 | 713 | </t>
|
|
935 | 935 | {
|
936 | 936 | "title": "Feature list",
|
937 | 937 | "type": "array",
|
938 |
| - "items": [ |
| 938 | + "prefixItems": [ |
939 | 939 | {
|
940 | 940 | "title": "Feature A",
|
941 | 941 | "properties": {
|
|
2130 | 2130 | "additionalProperties" and itself
|
2131 | 2131 | </t>
|
2132 | 2132 | <t>
|
2133 |
| - "additionalItems", whose behavior is defined in terms of "items" |
| 2133 | + "items", whose behavior is defined in terms of "prefixItems" |
2134 | 2134 | </t>
|
2135 | 2135 | <t>
|
2136 | 2136 | "unevaluatedItems", whose behavior is defined in terms of annotations
|
2137 |
| - from "items", "additionalItems" and itself |
| 2137 | + from "prefixItems", "items", "contains", and itself |
2138 | 2138 | </t>
|
2139 | 2139 | </list>
|
2140 | 2140 | </t>
|
|
2313 | 2313 | properties and array items, and combining their results.
|
2314 | 2314 | </t>
|
2315 | 2315 | <section title="Keywords for Applying Subschemas to Arrays">
|
2316 |
| - <section title="items"> |
| 2316 | + <section title="prefixItems"> |
2317 | 2317 | <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. |
2320 | 2319 | </t>
|
2321 | 2320 | <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. |
2329 | 2326 | </t>
|
2330 | 2327 | <t>
|
2331 | 2328 | This keyword produces an annotation value which is the largest
|
2332 | 2329 | index to which this keyword applied a subschema. The value
|
2333 | 2330 | 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". |
2341 | 2333 | </t>
|
2342 | 2334 | <t>
|
2343 | 2335 | Omitting this keyword has the same assertion behavior as
|
2344 |
| - an empty schema. |
| 2336 | + an empty array. |
2345 | 2337 | </t>
|
2346 | 2338 | </section>
|
2347 | 2339 |
|
2348 |
| - <section title="additionalItems" anchor="additionalItems"> |
| 2340 | + <section title="items" anchor="items"> |
2349 | 2341 | <t>
|
2350 |
| - The value of "additionalItems" MUST be a valid JSON Schema. |
| 2342 | + The value of "items" MUST be a valid JSON Schema. |
2351 | 2343 | </t>
|
2352 | 2344 | <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> |
2362 | 2357 | </t>
|
2363 | 2358 | <t>
|
2364 |
| - If the "additionalItems" subschema is applied to any |
| 2359 | + If the "items" subschema is applied to any |
2365 | 2360 | 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. |
2371 | 2363 | </t>
|
2372 | 2364 | <t>
|
2373 | 2365 | Omitting this keyword has the same assertion behavior as
|
|
2376 | 2368 | <t>
|
2377 | 2369 | Implementations MAY choose to implement or optimize this keyword
|
2378 | 2370 | 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. |
2380 | 2372 | Implementations that do not support annotation collection MUST do so.
|
2381 | 2373 | </t>
|
2382 | 2374 | </section>
|
|
2388 | 2380 | <t>
|
2389 | 2381 | The behavior of this keyword depends on the annotation results of
|
2390 | 2382 | 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", |
2392 | 2384 | which can come from those keywords when they are adjacent to the
|
2393 | 2385 | "unevaluatedItems" keyword. Those two annotations, as well as
|
2394 | 2386 | "unevaluatedItems", can also result from any and all adjacent
|
|
2397 | 2389 | defined in this document.
|
2398 | 2390 | </t>
|
2399 | 2391 | <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". |
2405 | 2399 | </t>
|
2406 | 2400 | <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. |
2418 | 2405 | </t>
|
2419 | 2406 | <t>
|
2420 | 2407 | If the "unevaluatedItems" subschema is applied to any
|
2421 | 2408 | positions within the instance array, it produces an
|
2422 | 2409 | 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". |
2427 | 2411 | </t>
|
2428 | 2412 | <t>
|
2429 | 2413 | Omitting this keyword has the same assertion behavior as
|
|
2446 | 2430 | array element even after the first match has been found. This
|
2447 | 2431 | is to ensure that all possible annotations are collected.
|
2448 | 2432 | </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> |
2449 | 2439 | </section>
|
2450 | 2440 | </section>
|
2451 | 2441 |
|
@@ -3787,9 +3777,9 @@ https://example.com/schemas/common#/$defs/count/minimum
|
3787 | 3777 | <t hangText="draft-handrews-json-schema-03">
|
3788 | 3778 | <list style="symbols">
|
3789 | 3779 | <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> |
3793 | 3783 | <t></t>
|
3794 | 3784 | <t></t>
|
3795 | 3785 | <t></t>
|
|
0 commit comments