Policies
Request Validation Policy
The Request Validation policy is used to validate incoming requests based on schemas in OpenAPI specifications.
When configured, any requests that do not conform to your OpenAPI schema will be
rejected with a 400: Bad Request
response containing a detailed error message
(in JSON) explaining why the request was not accepted.
Configuration
The configuration shows how to configure the policy in the 'policies.json' document.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
logLevel
<string> -The log level to use when logging validation errors.Allowed values areerror
,warn
,info
, anddebug
. Defaults to"info"
.validateBody
<string> -The action to perform when validation fails.Allowed values arenone
,log-only
,reject-and-log
, andreject-only
.validateQueryParameters
<string> -The action to perform when validation fails.Allowed values arenone
,log-only
,reject-and-log
, andreject-only
.validatePathParameters
<string> -The action to perform when validation fails.Allowed values arenone
,log-only
,reject-and-log
, andreject-only
.validateHeaders
<string> -The action to perform when validation fails.Allowed values arenone
,log-only
,reject-and-log
, andreject-only
.includeRequestInLogs
<boolean> -Whether to include the request in the logs.Defaults tofalse
.
Using the Policy
Here's an example of how to specify a schema for validation in a request body in OpenAPI.
Read more about how policies work