request-mime-type
OAS | Compatibility |
---|---|
2.0 | ✅ |
3.0 | ✅ |
3.1 | ✅ |
API design principles
All of my mime jokes have been edited out of here. I guess they didn't say much.
(get it?)
A good idea for request mime-types here is consistency.
Are you in the application/json
or application/x-www-form-urlencoded
camp? It doesn't matter to me... keep it consistent across your entire API if possible.
(Except for those application/octet-stream
or multipart/form-data
file uploads...)
Configuration
Option | Type | Description |
---|---|---|
severity | string | REQUIRED. Possible values: off , warn , error . |
allowedValues | [string] | REQUIRED. List of allowed request mime types. |
An example configuration:
rules:
request-mime-type:
severity: error
allowedValues:
- application/json
Examples
Given this configuration:
rules:
request-mime-type:
severity: error
allowedValues:
- application/json
Example of an incorrect request mime type:
paths:
/customers/{id}:
post:
requestBody:
content:
multipart/form-data:
# ...
Example of a correct request mime type:
paths:
/customers/{id}:
post:
requestBody:
content:
application/json:
# ...