array-max-items
Requires every resolved array schema to define maxItems.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Platinum |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient | Warning |
| Recommended–Complete | Error |
Intent
Bounded arrays make payload size predictable and reduce resource-exhaustion risk during validation, testing, and production use.
Flags
Schemas whose resolved type includes array and whose maxItems is absent. Referenced schemas are resolved.
See it fail
tags:
type: array
items:
type: string
Diagnostic: Array schemas should define \maxItems`.`
Fix it
tags:
type: array
maxItems: 20
items:
type: string
Configure
profiles:
default:
rules:
extends: [recommended]
override:
array-max-items: warn
Nearby: string-max-length-or-enum, integer-bounds-required.