Description
In OpenAPI 2.0, consumes tells clients which body formats a POST, PUT, or PATCH operation accepts.
Potential impact
The server may reject a request sent with the wrong Content-Type.
Remediation
List the formats the server accepts in the root consumes. Set it on an operation to override that list. Use application/json for JSON bodies and formData parameters for form fields.
Examples
This PUT accepts a JSON object. The excerpt omits the required id path parameter.
Before
yaml
swagger: "2.0"
paths:
/users/{id}:
put:
parameters:
- in: body
name: body
schema:
type: object
responses:
"200":
description: ok
After
yaml
swagger: "2.0"
paths:
/users/{id}:
put:
consumes:
- application/json
parameters:
- in: body
name: body
schema:
type: object
responses:
"200":
description: ok