Project: KICS (Provisioning / Security & Compliance)
File: 50de3b5b-6465-4e06-a9b0-b4c2ba34326b.md

title: Header Object Without Schema hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 50de3b5b-6465-4e06-a9b0-b4c2ba34326b Query name: Header Object Without Schema Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Networking and Firewall URL: The header object should have schema defined<br> ```json title="Positive test num. 1 - json file" hl_lines="72" { "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": { "description": "The number of allowed requests in the current period" } } } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="42" { "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": { "description": "The number of allowed requests in the current period" } }, "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="44" 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: description: The number of allowed requests in the current period ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="28" 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: description: The number of allowed requests in the current period 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": { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" } } } } } } } } } } } ``` ```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": { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" } } }, "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: description: The number of allowed requests in the current period schema: type: integer ``` <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: description: The number of allowed requests in the current period schema: type: integer 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>