Closed
Description
The items
keyword has an object form and an array form. The object form is used for constraining the items in an array while the array form is for constraining an array that is used like a tuple. This is something that trips up people new to JSON Schema.
It also causes confusion with the additionalItems
keyword. additionalItems
is only defined for use with the array form of items
, but I often see people throwing in "additionalItems": false
when they are using the object form. I'm not sure what they think that means, but it's not uncommon to see.
Proposal
- Redefine the
items
keyword to only support the current object form behaviour - Introduce the
tupleItems
keyword that supports the current array form ofitems
- Rename
additionalItems
toadditionalTupleItems
to make it clear that it works with thetupleItems
keyword not theitems
keyword. - Rename
unevaluatedItems
tounevaluatedTupleItems
to make it clear that it works with thetupleItems
keyword not theitems
keyword.
Pros
- Less confusing for JSON Schema noobs and veterans alike
- Better errors. If you try to use an array for
items
when you meant the object form (and vis versa) meta-schema validation will fail making it more clear where your problem is.
Cons
- Redefining an existing keyword is a backwards incompatible change
- OAS is skeptical of additional changes at this stage