This rule checks whether requests and responses use only standard media types.
Using non-standard media types can lead to interoperability issues in the API’s structure.
The standard-media-types
rule is designed to ensure that all requests and
responses in a schema use only standard media types. The rule works by
iterating over all the requests and responses defined in the schema and
checking if they use any non-standard media types. If such a media type is
found, the rule raises a warning.
None.
Good.
paths:
/users:
get:
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/User"
Bad. application/x-custom
is not a standard media type.
paths:
/users:
get:
responses:
"200":
description: OK
content:
application/x-custom:
schema:
$ref: "#/components/schemas/User"
We recommend to always enable this rule.
This rule is compatible with all OpenAPI 3.x versions.