OpenAPI errors

How to fix "requestBody content is required" in OpenAPI

An OpenAPI Request Body Object must have a content map. Setting only required: true says that a body is mandatory, but it does not define any supported media type or payload schema.

Broken YAML

This request body has no content field:

openapi: 3.1.0
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    post:
      operationId: createUser
      requestBody:
        required: true
      responses:
        '201':
          description: User created

Why it fails

content is the only required fixed field in a Request Body Object. Its keys are media types or media type ranges. Each value is a Media Type Object that can define the payload schema and examples.

Redocly reports The field content must be present on this level at requestBody. The boolean required is optional and has a different purpose. It cannot stand in for the content definition.

Corrected YAML

Add an application/json entry and its schema:

openapi: 3.1.0
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    post:
      operationId: createUser
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
      responses:
        '201':
          description: User created

OpenAPI 3.0 vs 3.1

OpenAPI 3.0 and OpenAPI 3.1 both require content in a Request Body Object. Both permit multiple media types when an operation accepts more than one representation.

The payload schema dialect differs. OpenAPI 3.1 supports the full JSON Schema 2020-12 vocabulary. OpenAPI 3.0 uses its earlier Schema Object rules. Keep the content wrapper in both versions.

Specification sections: OpenAPI 3.0.4 and OpenAPI 3.1.1.

Validate the fix

Save the complete document as openapi.yaml, then run:

pnpm --package=@redocly/cli@2.53.3 dlx redocly lint openapi.yaml --extends=minimal

The corrected request body removes the structural missing-content error. This check does not prove that the server accepts the declared media type, so test one real request as well.