An input constraint restricts what an API field may accept, such as its type, length, allowed values, format, or number of items. Schema linting checks strings, integers, and arrays for missing restrictions. section 12.2
Review input schemas for constraints such as:
- maximum length, enumeration, or constant values for strings section 12.2
- minimum and maximum values for integers section 12.2
- maximum item counts for arrays section 12.2
API schema findings
Spectral flags components.schemas.RegisterStudent.properties.last_name because the string has no maxLength, enum, or const. It similarly flags courses.get parameters without minimum and maximum, and GetCourse.properties.lessons without maxItems. Review these findings especially for schemas that accept input; missing constraints are less problematic for read-only schemas whose output the API controls. section 12.2
npx spectral lint openapi.json --ruleset `pwd`/.spectral.yaml
Run Spectral against the OpenAPI specification to find missing string, integer, and array constraints. section 12.2
