Missing header value definition

Define an OpenAPI 3.0 header's value using schema or content.

Description

An OpenAPI 3.0 response header needs a definition of its value. A description alone leaves the type unspecified.

Potential impact

An SDK may treat a numeric header as text or parse it incorrectly.

Remediation

Set schema to the header’s type and constraints, or use content for a single media type. For a shared header, check the definition referenced by $ref.

Examples

The example adds type: integer to the schema for X-Rate-Limit-Limit, the number of requests allowed in the current period.

Before

json
{
  "openapi": "3.0.0",
  "components": {
    "responses": {
      "ResponseExample": {
        "headers": {
          "X-Rate-Limit-Limit": {
            "description": "The number of allowed requests in the current period"
          }
        }
      }
    }
  }
}

After

json
{
  "openapi": "3.0.0",
  "components": {
    "responses": {
      "ResponseExample": {
        "headers": {
          "X-Rate-Limit-Limit": {
            "description": "The number of allowed requests in the current period",
            "schema": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}

References