Project: KICS (Provisioning / Security & Compliance)
File: d4e43db5-54d8-4dda-b3c2-0dc6f31a46bd.md

title: Header Response Name Is Invalid (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: d4e43db5-54d8-4dda-b3c2-0dc6f31a46bd Query name: Header Response Name Is Invalid (v3) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Best Practices URL: The Header Response should not be named as 'Content-Type', 'Authorization' or 'Accept'. If so, it will be ignored.<br> ```json title="Positive test num. 1 - 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": { "Content-Type": { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } } } }, "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. 2 - yaml file" 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: http://127.0.0.1:8774/v2/ rel: self "6xx": description: "[600-699] response" headers: Content-Type: application/json: schema: $ref: "#/components/schemas/Pet" 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 ``` ```json title="Positive test num. 3 - json file" hl_lines="32 14" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/responses/Success" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "responses": { "Success": { "description": "An array with users", "schema": { "$ref": "#/definitions/User" }, "headers": { "Accept": { "description": "When it is accepted", "type": "string" } } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } } } } } ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="12 21" swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: '200': "$ref": "#/responses/Success" parameters: "$ref": "#/parameters/limitParam" responses: Success: description: An array with users schema:

"#/definitions/User" headers: Accept: description: When it is accepted type: string parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string ``` </details> ```json title="Negative test num. 1 - 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": { "Pet": { "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } } } }, "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. 2 - yaml 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: 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: Pet: application/json: schema: $ref: "#/components/schemas/Pet" 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 ``` ```json title="Negative test num. 3 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/responses/Success" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "responses": { "Success": { "description": "An array with users", "schema": { "$ref": "#/definitions/User" }, "headers": { "X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", "type": "integer" } } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: '200': "$ref": "#/responses/Success" parameters: "$ref": "#/parameters/limitParam" responses: Success: description: An array with users schema: "$ref": "#/definitions/User" headers: X-Rate-Limit-Limit: description: The number of allowed requests in the current period type: integer parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string ``` </details>