Invalid Media Type Value (v2)
- Query id: f985a7d2-d404-4a7f-9814-f645f791e46e
- Query name: Invalid Media Type Value (v2)
- Platform: OpenAPI
- Severity: Info
- Category: Best Practices
- CWE: 710
- URL: Github
Description¶
The Media Type value should match the following format:
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"produces": [
"image/ png",
"image/gif",
"image/jpeg"
],
"consumes": [
"application/ x-www-form-urlencoded"
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
Positive test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
produces:
- image/ png
- image/gif
- image/jpeg
consumes:
- application/ x-www-form-urlencoded
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"produces": [
"image/png",
"image/gif",
"image/jpeg"
],
"consumes": [
"application/x-www-form-urlencoded"
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
Negative test num. 2 - yaml file
swagger: "2.0"
info:
title: Simple API Overview
version: 1.0.0
paths:
"/":
get:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
produces:
- image/png
- image/gif
- image/jpeg
consumes:
- application/x-www-form-urlencoded