spectral:oas error on by default

array-items

Applies to
items
Selects
#ArrayProperties
Function
truthy
Specs
OpenAPI 2.0OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
Message
Schemas with "type: array", require a sibling "items" field

Use it

This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:

extends: spectral:oas
rules:
  array-items: error   # or off, or another severity

Definition

As defined in @openlint/openlint-rulesets. Functions show by name.

array-items:
  message: 'Schemas with "type: array", require a sibling "items" field'
  severity: 0
  recommended: true
  given: '#ArrayProperties'
  resolved: false
  then:
    function: truthy
    field: items

About this rule

Schemas with type: array, require a sibling items field.

Good Example

TheGoodModel:
  type: object
  properties:
    favoriteColorSets:
      type: array
      items:
        type: array
        items: {}

Bad Example

TheBadModel:
  type: object
  properties:
    favoriteColorSets:
      type: array
      items:
        type: array

Sources