400, so your code only sees requests the spec allows. The path, query parameters, headers, and body are all checked. OpenAPI 3.0 and 3.1 are supported.
Set it up
- Serve your OpenAPI document from your app, for example at
/openapi.yaml. - Set that path as
openapiSpecPathin the ’s runtime settings, in the app’s settings or withenvironments.updateSettings. It must start with/and be at most 512 characters. - Add the policy: open the app, go to Policies, click Add Policy, and pick OpenAPI Validation. There’s nothing else to configure.
- Deploy. When the succeeds, we fetch the spec from it over HTTPS and save it with that deployment.
Example
What callers see
A request that fails the check gets400 openapi_validation_failed. The message describes the first problem and, when there is one, the field that caused it. No later policies run, and the request isn’t logged.
An Authorization header with the wrong scheme isn’t reported here, because the API key authentication policy gives a clearer error. A missing Authorization header that the spec requires still fails.
Troubleshooting
Requests aren’t being checked
If the deployment has no spec, the policy does nothing and requests pass through. A deployment has no spec when:openapiSpecPathisn’t set.- The path returns a
404or an empty response. - The document is over 10 MiB.
- Another policy blocked the request for the spec. We fetch it through the gateway like any other request, so keep the spec path out of your API key and firewall policies’ match expressions.
Every request fails with 422
If the spec is invalid, for example it has a broken schema, every matching request gets422 invalid_configuration. Fix the spec and redeploy.
Hide fields in request logs
Addx-unkey-redact: true to a property in your spec, and its value is hidden in request and response bodies saved by a logging policy. Only that property is hidden, not others with the same name elsewhere in your schemas. Your app still receives the full request.
Next steps
Logging policy
Capture bodies so redaction has something to protect.
Gateway errors
The shape of the 400 and 422 responses.