OpenAPI errors

How to fix "parameter must contain schema or content" in OpenAPI

An OpenAPI Parameter Object must define how its value is serialized. For most query, header, path, and cookie parameters, that means adding a schema.

Broken YAML

The limit parameter has a name and location but no value definition:

openapi: 3.1.0
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    get:
      operationId: listUsers
      parameters:
        - name: limit
          in: query
      responses:
        '200':
          description: Users returned

Why it fails

The Parameter Object must contain either schema or content. Without one of these fields, a validator and generated client do not know whether limit is a string, integer, array, or another value.

Redocly reports Must contain at least one of the following fields: schema, content at the parameter. The two forms are alternatives. Use schema for normal parameter serialization. Use content only when one media type describes a more complex encoded parameter.

Corrected YAML

Define limit as a positive integer:

openapi: 3.1.0
info:
  title: Users API
  version: 1.0.0
paths:
  /users:
    get:
      operationId: listUsers
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
      responses:
        '200':
          description: Users returned

OpenAPI 3.0 vs 3.1

OpenAPI 3.0 and OpenAPI 3.1 both require a Parameter Object to use schema or content. The content map can contain only one media type in both versions.

The schemas inside these fields follow different dialects. For example, OpenAPI 3.0 uses nullable: true, while OpenAPI 3.1 can include null in the schema type. This difference does not change the requirement to supply one value definition.

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 parameter removes the structural schema, content error. Address any unrelated minimal preset warnings separately.