Ensures that example objects have valid field combinations according to the OpenAPI 3.2.0 specification.
| OAS | Compatibility |
|---|---|
| 2.0 | ❌ |
| 3.0 | ✅ |
| 3.1 | ✅ |
| 3.2 | ✅ |
According to the OpenAPI 3.2.0 specification, example objects have strict rules about which fields can be used together. This rule ensures that only valid field combinations are used in example objects.
| Option | Type | Description |
|---|---|---|
| severity | string | Possible values: off, warn, error. Default error (in recommended configuration). |
An example configuration:
rules:
spec-example-values: errorGiven this configuration:
rules:
spec-example-values: errorExample of incorrect example objects:
components:
examples:
InvalidDataValueAndValue:
dataValue:
name: John Doe
value:
name: Jane Doe
InvalidSerializedValueAndValue:
serializedValue: '{"name":"John Doe"}'
value:
name: Jane Doe
InvalidExternalValueAndValue:
externalValue: https://example.com/user-example.json
value:
name: Jane DoeExample of correct example objects:
components:
examples:
ValidDataValue:
dataValue:
name: John Doe
ValidSerializedValue:
serializedValue: '{"name":"John Doe"}'
ValidExternalValue:
externalValue: https://example.com/user-example.json- struct
- no-example-value-and-externalValue
- spec-no-invalid-encoding-combinations
- spec-discriminator-defaultMapping
- spec-no-invalid-tag-parents