Securityschema validationrequest validation

Input validation

Definition

Input validation verifies untrusted input against an explicit specification, such as an OpenAPI or JSON Schema, and rejects requests that do not conform, ideally both at the edge and in the service.

In practice

Every request, partner payload and webhook is untrusted. Validating types, lengths, formats, enums and rejecting unknown properties (additionalProperties: false) blocks malformed data, oversized payloads and many injection attempts early, and gives clients clear 400 errors. Limits on body size, page size and query depth also protect capacity.

Validation checks shape, not permission: a perfectly valid request for someone else's order is still BOLA. It does not replace parameterised queries or output encoding either, because data that is valid in one context can be dangerous in another. Prefer allowlists to blocklists, and validate again in the service rather than trusting the gateway alone.

Example

The schema for POST /orders requires quantity as an integer from 1 to 100 and sku matching ^[A-Z0-9-]{4,20}$; a request with quantity: -5 or an extra price field gets 400.