Missing OpenAPI 3.0 header reference target

Point header references to existing Header Objects.

Description

A shared response header’s component name is case-sensitive in components.headers. HTTP header names themselves are case-insensitive.

Potential impact

A broken reference can leave the header format undocumented or prevent client generation.

Remediation

Correct the path and name in the local $ref. For an external reference, check the file and the path within it. Validate the specification after the change.

Examples

Before

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MyObject"
                  }
                }
              }
            },
            "headers": {
              "X-Pages": {
                "$ref": "#/components/headers/wPages"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "MyObject": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "headers": {
      "xPages": {
        "schema": {
          "type": "integer",
          "description": "number of pages"
        }
      }
    }
  }
}

After

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MyObject"
                  }
                }
              }
            },
            "headers": {
              "X-Pages": {
                "$ref": "#/components/headers/xPages"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "MyObject": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "headers": {
      "xPages": {
        "schema": {
          "type": "integer",
          "description": "number of pages"
        }
      }
    }
  }
}

In the 200 response, X-Pages switches from the undefined wPages to xPages, which describes the page count as an integer.

References