| slug | /docs/cli/rules/oas/spec-no-invalid-encoding-combinations |
|---|
Ensures that MediaType objects have valid combinations of encoding fields according to the OpenAPI 3.2.0 specification.
| OAS | Compatibility |
|---|---|
| 2.0 | ❌ |
| 3.0 | ❌ |
| 3.1 | ❌ |
| 3.2 | ✅ |
flowchart TD
Root ==> Paths --> PathItem --> Operation --> Parameter --> MediaType
PathItem --> Parameter
Operation --> RequestBody --> MediaType
Operation --> Responses --> MediaType
style MediaType fill:#codaf9,stroke:#0044d4,stroke-width:5px
According to the OpenAPI 3.2.0 specification, MediaType objects have strict rules about which encoding fields can be used together. This rule ensures that only valid encoding field combinations are used in MediaType objects.
| Option | Type | Description |
|---|---|---|
| severity | string | Possible values: off, warn, error. Default error (in recommended configuration). |
An example configuration:
rules:
spec-no-invalid-encoding-combinations: errorGiven this configuration:
rules:
spec-no-invalid-encoding-combinations: errorExample of incorrect MediaType objects:
requestBody:
content:
'multipart/form-data':
schema:
type: object
properties:
id:
type: integer
encoding:
id:
style: form
prefixEncoding:
- style: form
'application/x-www-form-urlencoded':
schema:
type: object
properties:
name:
type: string
encoding:
name:
style: form
itemEncoding:
style: formExample of correct MediaType objects:
requestBody:
content:
'multipart/form-data':
schema:
type: object
properties:
id:
type: integer
encoding:
id:
style: form
'multipart/form-data-positional':
schema:
type: object
properties:
items:
type: array
prefixEncoding:
- style: form
itemEncoding:
style: form