spec-example-values

October 16, 2025 · View on GitHub

Ensures that example objects have valid field combinations according to the OpenAPI 3.2.0 specification.

OASCompatibility
2.0
3.0
3.1
3.2
flowchart TD

Root ==> Paths --> PathItem --> Operation --> MediaType --> Example
                                              MediaType --> Examples --> Example
Root ==> components

subgraph components
NamedExamples
end

NamedExamples --> Example

style Example fill:#codaf9,stroke:#0044d4,stroke-width:5px

API design principles

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.

Configuration

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

An example configuration:

rules:
  spec-example-values: error

Examples

Given this configuration:

rules:
  spec-example-values: error

Example 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 Doe

Example of correct example objects:

components:
  examples:
    ValidDataValue:
      dataValue:
        name: John Doe
    ValidSerializedValue:
      serializedValue: '{"name":"John Doe"}'
    ValidExternalValue:
      externalValue: https://example.com/user-example.json

Resources