no-schema-content-media-type-for-pre-defined-file-media-type-value
Overview
This rule belongs to the openapi-v3-standards-validation
ruleset and states that:
The media type for a file upload can be specified in several ways e.g. by using the content key when defining the Media Type Object, the contentType
property in the Media Type Object's encoding
information, or the contentMediaType
property in the Media Type Object's schema
definition. When the media type is already specified using the Media Type Object's key, or by the contentType
field of an Encoding Object, the contentMediaType
keyword will be ignored if present.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Warning |
Message | File's media type is already specified, therefore, the value of contentMediaType in the Media Object schema will be ignored. |
Code | OPENAPI3STANDARDS_V136 |
Type | Validation |
Rule System | Semantic |
Broad Category | Media Types |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic validation file media type content type content schema encoding |
Suggested Fixes
- Remove the
contentMediaType
property from the Schema Object unless the schema definition is placed in an external/non-OAS document and may be independently used outside OpenAPI context as well. - Remove the
contentType
property from the Encoding Object referenced by the Media Type Object'sencoding
definition if it is redundant.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#considerations-for-file-uploads
- 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#mediaTypeEncoding
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#encoding-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#mediaTypeSchema
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schemaObject
- https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-8.4
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/