Ensures that Parameter and Header objects have valid combinations of fields according to the OpenAPI specification.
| OAS | Compatibility |
|---|---|
| 2.0 | ❌ |
| 3.0 | ✅ |
| 3.1 | ✅ |
| 3.2 | ✅ |
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: paththat does not haverequired: true. - A parameter with
in: pathwhosenamecontains{or}. Such a name cannot match a template expression in the path. - A parameter or a header with both
schemaandcontent. - A parameter or a header with both
exampleandexamples.
A description with one of these combinations is not valid, and tools can read it in different ways.
| Option | Type | Description |
|---|---|---|
| severity | string | Possible values: off, warn, error. Default warn (in recommended configuration). |
An example configuration:
rules:
spec-no-invalid-parameter-combinations: error
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