Project: KICS (Provisioning / Security & Compliance)
File: 2d6646f4-2946-420f-8c14-3232d49ae0cb.md

title: Header Object With Incorrect Ref hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 2d6646f4-2946-420f-8c14-3232d49ae0cb Query name: Header Object With Incorrect Ref Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Header Object reference must always point to '#/components/headers'<br> ```json title="Positive test num. 1 - json file" hl_lines="73" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.c" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } }, "components": { "responses": { "ResponseExample": { "description": "200 response", "content": { "application/json": { "schema": { "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "binary" }, "message": { "type": "string" } }, "type": "object" }, "encoding": { "code": { "headers": { "X-Rate-Limit-Limit": { "$ref": "#components/h" } } } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="43" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "50": { "description": "500 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } }, "6xx": { "description": "[600-699] response", "headers": { "X-Rate-Limit-Limit": { "$ref": "#components/h" } }, "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="45" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self components: responses: ResponseExample: description: 200 response content: application/json: schema: type: object discriminator: propertyName: petType properties: code: type: string format: binary message: type: string encoding: code: headers: X-Rate-Limit-Limit: $ref: "#components/h" ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="29" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "50": description: Server error response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href:

rel: self "6xx": description: "[600-699] response" headers: X-Rate-Limit-Limit: $ref: "#components/h" content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.c" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } }, "components": { "responses": { "ResponseExample": { "description": "200 response", "content": { "application/json": { "schema": { "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "binary" }, "message": { "type": "string" } }, "type": "object" }, "encoding": { "code": { "headers": { "X-Rate-Limit-Limit": { "$ref": "#/components/headers/" } } } } } } } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "50": { "description": "500 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } }, "6xx": { "description": "[600-699] response", "headers": { "X-Rate-Limit-Limit": { "$ref": "#/components/headers/" } }, "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } } } ``` ```yaml title="Negative test num. 3 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self components: responses: ResponseExample: description: 200 response content: application/json: schema: type: object discriminator: propertyName: petType properties: code: type: string format: binary message: type: string encoding: code: headers: X-Rate-Limit-Limit: $ref: "#/components/headers/" ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "50": description: Server error response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self "6xx": description: "[600-699] response" headers: X-Rate-Limit-Limit: $ref: "#/components/headers/" content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self ``` </details>