# OAS Validator Configuration

The `oas-validator` plugin checks incoming HTTP requests against an OpenAPI specification before they are forwarded to upstream services.<!-- --> <!-- -->Configuration covers plugin parameters and plugin metadata.

## Parameters[​](#parameters "Direct link to Parameters")

See plugin [common configurations](https://docs.api7.ai/apisix/reference/plugin-common-configurations.md) for configuration options available to all plugins.

* spec

  string

  ***

  String containing the OpenAPI spec. Mutually exclusive with `spec_url`.

  The inline spec has a 2 MB size limit imposed by the control plane. If your OpenAPI specification exceeds this limit, use `spec_url` instead to load the spec from a remote URL.

* spec\_url

  string

  ***

  URL to fetch the OpenAPI spec from (must start with `http://` or `https://`). Mutually exclusive with `spec`. The fetched spec is cached with a configurable TTL (see plugin metadata `spec_url_ttl`), and stale entries continue serving requests while the spec refreshes in the background.

  Available in API7 Enterprise from version 3.9.12 and APISIX from version 3.17.0.

* spec\_url\_request\_headers

  object

  ***

  Custom HTTP headers to include when fetching `spec_url` (e.g. for authentication).

  Available in API7 Enterprise from version 3.9.12 and APISIX from version 3.17.0.

* ssl\_verify

  boolean

  default: `` `true` in APISIX 3.20.0; `false` in API7 Enterprise 3.9.23 and 3.10.10 ``

  ***

  Whether to verify the TLS certificate when fetching `spec_url`. APISIX 3.20.0 changed the default from `false` to `true`. API7 Enterprise 3.9.23 and 3.10.10 retain the `false` default.

  Set this field to `false` only as an explicit compatibility opt-out. An unverified connection can let an on-path attacker replace the specification and receive credentials configured in `spec_url_request_headers`.

  Available in API7 Enterprise from version 3.9.12 and APISIX from version 3.17.0.

* timeout

  integer

  default: `10000`

  valid value:

  1000–60000

  ***

  HTTP request timeout in milliseconds when fetching `spec_url`.

  Available in API7 Enterprise from version 3.9.12 and APISIX from version 3.17.0.

* verbose\_errors

  boolean

  default: `false`

  ***

  If true, respond with detailed error if the validation fails.

* skip\_request\_body\_validation

  boolean

  default: `false`

  ***

  If true, skip the validation of request body.

* skip\_request\_header\_validation

  boolean

  default: `false`

  ***

  If true, skip the validation of request header.

* skip\_query\_param\_validation

  boolean

  default: `false`

  ***

  If true, skip the validation of query parameters.

* skip\_path\_params\_validation

  boolean

  default: `false`

  ***

  If true, skip the validation of path parameters.

* reject\_if\_not\_match

  boolean

  default: `true`

  ***

  If false, requests that fail OAS validation are logged as error but the request is still forwarded to the upstream service.

  Available in API7 Enterprise from 3.9.6 and APISIX from version 3.17.0.

* rejection\_status\_code

  integer

  default: `400`

  valid value:

  400–599

  ***

  HTTP status code to return when request validation fails. For example, set to `422` to distinguish semantic validation errors (Unprocessable Entity) from malformed request syntax (`400` Bad Request). Only effective when `reject_if_not_match` is `true`.

  Available in API7 Enterprise from version 3.9.8 and APISIX from version 3.17.0.

* max\_req\_body\_size

  integer

  default: `67108864`

  valid value:

  greater than or equal to 1

  ***

  Maximum request body size in bytes read for OpenAPI validation. A larger body returns `500 Internal Server Error`. This field has no effect when `skip_request_body_validation` is `true`. Introduced in API7 Enterprise 3.9.17 and 3.10.4, and APISIX 3.18.0.

note

One of `spec` or `spec_url` must be configured. They are mutually exclusive.

## Plugin Metadata[​](#plugin-metadata "Direct link to Plugin Metadata")

* spec\_url\_ttl

  integer

  default: `3600`

  ***

  TTL in seconds for cached specs fetched from `spec_url`. After expiry, stale entries continue serving requests while the spec refreshes asynchronously in the background.

  Available in API7 Enterprise from version 3.9.12 and APISIX from version 3.17.0.

  A spec that no request has used for `spec_url_ttl` seconds is released from memory. This idle-cache cleanup is available in APISIX 3.20.0 and API7 Enterprise 3.9.22 and 3.10.9.
