oas2-operation-formData-consume-check
Operations with the in: formData
parameter,
must include ‘application/x-www-form-urlencoded’ or ‘multipart/form-data’ in their consumes
property.
Why did this violation appear?
When using in: formData
, the consumes
property needs to be set to a valid type.
Bad example
swagger: 2.0
paths:
/survey:
parameters:
- in: formData
name: "name"
type: string
description: "A person's name."
- in: formData
name: "fav_number"
type: number
description: "A person's favorite number"
post:
consumes:
- "chicken-soup/and-cake"
...
Good example
swagger: 2.0
paths:
/survey:
parameters:
- in: formData
name: "name"
type: string
description: "A person's name."
- in: formData
name: "fav_number"
type: number
description: "A person's favorite number"
post:
consumes:
- "application/x-www-form-urlencoded"
...
How do I fix this violation?
Ensure any consumes
definitions that are using parameters defined with in: formData
, are set to either
‘application/x-www-form-urlencoded’ or ‘multipart/form-data’
Spectral Equivalent
The rule is equivalent to oas2-operation-formData-consume-check