array
The array type provides a way of defining a list of other types through providing an items attribute that represents the schema of the type contained in the array.
# An array of stringschema:type: arrayitems:type: string# An array of objectsschema:type: arrayitems:type: objectproperties:name:type: stringage:type: integer# An array of arbitrary thingsschema:type: arrayitems: {}
The array type will support any schema that describes any other type in its items attribute including types using oneOf/anyOf/allOf attributes. The array type also has some optional attributes for additional validation:
- minItems - The minimum number of items the array must contain.
- maxItems - The maximum number of items the array must contain.
- uniqueItems - The array must contain only unique items.
# An array of floats that must contain at least 1 element.schema:type: arrayitems:type: numberformat: floatminItems: 1# An array of strings that must contain at most 10 elements.schema:type: arrayitems:type: stringmaxItems: 10# An array of booleans that must contain exactly 3 elements.schema:type: arrayitems:type: booleanminItems: 3maxItems: 3# An array of strings that must contain only unique elements.schema:type: arrayitems:type: stringuniqueItems: true