Skip to content
Last updated

spec-no-invalid-parameter-combinations

Ensures that Parameter and Header objects have valid combinations of fields according to the OpenAPI specification.

OASCompatibility
2.0❌
3.0✅
3.1✅
3.2✅

Root

Paths

PathItem

Operation

Parameter

Responses

Header

Components

Root

Paths

PathItem

Operation

Parameter

Responses

Header

Components

API design principles

The Parameter Object has requirements that depend on more than one field, so the struct rule cannot check them. This rule reports the following combinations:

  • A parameter with in: path that does not have required: true.
  • A parameter with in: path whose name contains { or }. Such a name cannot match a template expression in the path.
  • A parameter or a header with both schema and content.
  • A parameter or a header with both example and examples.

A description with one of these combinations is not valid, and tools can read it in different ways.

Configuration

OptionTypeDescription
severitystringPossible values: off, warn, error. Default warn (in recommended configuration).

An example configuration:

rules:
  spec-no-invalid-parameter-combinations: error

Examples

Given this configuration:

rules:
  spec-no-invalid-parameter-combinations: error

Example of incorrect parameters:

paths:
  /orders/{orderId}:
    get:
      parameters:
        - name: orderId
          in: path
          required: false
          schema:
            type: string
        - name: status
          in: query
          schema:
            type: string
          content:
            application/json:
              schema:
                type: string
        - name: limit
          in: query
          schema:
            type: integer
          example: 10
          examples:
            small:
              value: 10

Example of correct parameters:

paths:
  /orders/{orderId}:
    get:
      parameters:
        - name: orderId
          in: path
          required: true
          schema:
            type: string
        - name: status
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
          examples:
            small:
              value: 10

Resources