Project: KICS (Provisioning / Security & Compliance)
File: 4cd8de87-b595-48b6-ab3c-1904567135ab.md

title: Encoding Header 'Content-Type' Improperly Defined hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 4cd8de87-b595-48b6-ab3c-1904567135ab Query name: Encoding Header 'Content-Type' Improperly Defined Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Best Practices URL: Encoding Map Key should not define a 'Content-Type' in the 'headers' field. If so, it will be ignored.<br> ```json title="Positive test num. 1 - json file" hl_lines="70" { "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": { "profileImage": { "headers": { "Content-Type": { "contentType": "image/png, image/jpeg" } } } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="36" { "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": { "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "binary" }, "message": { "type": "string" } } }, "encoding": { "profileImage": { "headers": { "Content-Type": { "contentType": "image/png, image/jpeg" } } } } } } } }, "operationId": "listVersionsv2", "summary": "List API versions" } } } } ``` ```yaml title="Positive test num. 3 - yaml 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: "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: profileImage: headers: Content-Type: contentType: image/png, image/jpeg ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="26" openapi:

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: schema: type: object discriminator: propertyName: petType properties: code: type: string format: binary message: type: string encoding: profileImage: headers: Content-Type: contentType: image/png, image/jpeg ``` </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": { "contentType": "image/png, image/jpeg" } } } } } } } } ``` ```json title="Negative test num. 2 - 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": { "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "binary" }, "message": { "type": "string" } } }, "encoding": { "code": { "contentType": "image/png, image/jpeg" } } } } } }, "operationId": "listVersionsv2", "summary": "List API versions" } } } } ``` ```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: contentType: image/png, image/jpeg ``` <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: "200": description: 200 response content: application/json: schema: type: object discriminator: propertyName: petType properties: code: type: string format: binary message: type: string encoding: code: contentType: image/png, image/jpeg ``` </details>