Couper Documentation

v1.14

OpenAPI

The openapi block configures the backend’s proxy behavior to validate outgoing and incoming requests to and from the origin, preventing the origin from invalid requests and the Couper client from invalid answers. To do so Couper uses the OpenAPI 3 standard to load the definitions from a given document defined with the file attribute.

⚠️ While ignoring request violations an invalid method or path would lead to a non-matching route which is still required for response validations. In this case the response validation will fail if not ignored, too.

Block nameContextLabel
openapiBackend Blockno label

Attributes

NameTypeDefaultDescription
file
string
-
OpenAPI YAML definition file.
ignore_request_violations
bool
false
Logs request validation results, skips error handling.
ignore_response_violations
bool
false
Logs response validation results, skips error handling.

Empty query parameter values

A query parameter that is present without a value (?q or ?q=) is validated as an empty string. For a parameter with type: string an empty string satisfies both required: true and the default allowEmptyValue: false, so such a request passes request validation. A parameter of any other type — integer, for example — is still rejected, and a parameter that is absent altogether still fails the required check.

Use minLength: 1 in the parameter schema to reject empty values:

parameters:
  - in: query
    name: q
    required: true
    schema:
      type: string
      minLength: 1

Example

openapi {
  file = "openapi.yaml"
  ignore_response_violations = true
}

You can find a detailed example here.