Skip to main content

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.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageMultipart property uses contentMediaType without contentEncoding.
CodeOPENAPI3STANDARDS_L081
TypeLinting
Rule SystemSemantic
Broad CategoryMedia Types
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi standards semantic linting contentMediaType contentEncoding content media type multipart schema property

Suggested Fixes

  • If the content will be encoded, use contentEncoding to specify related information.
  • Remove contentMediaType from the property schema definition if contentEncoding is not expected to be added.

For More Information