multipart-property-content-media-type-only-with-content-encoding
Overview
This rule belongs to the openapi-v3-standards-linting ruleset and states that:
Use of contentMediaType without contentEncoding is not recommended for multipart property definitions. Per the JSON Schema specification, contentMediaType without contentEncoding present is treated as if contentEncoding: identity were present. While useful for embedding text documents such as text/html into JSON strings, it is not useful for a multipart/form-data part, as it just causes the document to be treated as text/plain instead of its actual media type.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Warning |
| Message | Multipart property uses contentMediaType without contentEncoding. |
| Code | OPENAPI3STANDARDS_L081 |
| Type | Linting |
| Rule System | Semantic |
| Broad Category | Media Types |
| Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
| Tags | openapi3 openapi standards semantic linting contentMediaType contentEncoding content media type multipart schema property |
Suggested Fixes
- If the content will be encoded, use
contentEncodingto specify related information. - Remove
contentMediaTypefrom the property schema definition ifcontentEncodingis not expected to be added.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#special-considerations-for-multipart-content
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md
- https://docs.apimatic.io/rulesets/overview/