Skip to main content

valid-request-body-content-key

Overview

This rule belongs to the openapi-v3-syntax-linting ruleset and states that:

The request body content key can be a specific media type (e.g. application/json) or a wildcard media type range (e.g. image/*). Media type definitions must be in compliance with RFC6838.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageThe key of the request body content definition is invalid.
CodeOPENAPI3SYNTAX_L060
TypeLinting
Rule SystemSyntax
Broad CategoryRequest Body
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi syntax linting media type content request body body

Suggested Fixes

  • A media type consists of a top-level type and a subtype, which is further structured into a tree. A media type can optionally define a suffix and parameters as well.
  • A media type follows a pattern like the following where segments between [] are optional segments: <type>/[<tree>.]<subtype>[+<suffix>]*[;<parameter>]
  • Some examples of valid media types are: application/json, application/vnd.api+json, text/plain.
  • Media type ranges use the asterisk '' character to group media types into ranges, with '/' indicating all media types and 'type/' indicating all subtypes of that type. The media-range can include media type parameters that are applicable to that range. Each media-range might be followed by zero or more applicable media type parameters (e.g., charset).
  • Some examples of media type ranges include /, text/. Here text/ media type range is more specific than / and has more precedence.

For More Information