Skip to content

Split items into items and tupleItems #864

Closed
@jdesrosiers

Description

@jdesrosiers

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 of items
  • Rename additionalItems to additionalTupleItems to make it clear that it works with the tupleItems keyword not the items keyword.
  • Rename unevaluatedItems to unevaluatedTupleItems to make it clear that it works with the tupleItems keyword not the items 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clarificationItems that need to be clarified in the specificationcore

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions