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:

Copy
Copied
styleguide:
  rules:
    request-mime-type:
      severity: error
      allowedValues:
        - application/json

Examples

Given this configuration:

Copy
Copied
styleguide:
  rules:
    request-mime-type:
      severity: error
      allowedValues:
        - application/json

Example of an incorrect request mime type:

Copy
Copied
paths:
  /customers/{id}:
    post:
      requestBody:
        content:
          multipart/form-data:
            # ...

Example of a correct request mime type:

Copy
Copied
paths:
  /customers/{id}:
    post:
      requestBody:
        content:
          application/json:
            # ...

Related rules

Resources