Skip to main content

no-server-variables-empty-enum

Validates enum on variables in the root servers list.

AttributeValue
CategoryMetadata
MaturityBaseline
OpenAPIOpenAPI 3.0, 3.1, 3.2
All rulesetsError

Intent

A server-variable enum must offer usable choices, and its default must be one of them.

Flags

  • A present enum that is not an array or is empty.
  • A variable defining both enum and default when the enum does not contain the exact default value.

An invalid non-array enum with a default can produce both findings.

Does not flag

Variables without enum, nonempty enums with no default, or enums containing their default. Only root-level servers are inspected.

See it fail

servers:
- url: https://{environment}.example.test
variables:
environment:
default: production
enum: []

Fix it

servers:
- url: https://{environment}.example.test
variables:
environment:
default: production
enum: [production, staging]

Configure

profiles:
default:
rules:
extends: [recommended]
override:
no-server-variables-empty-enum: warn

Nearby: no-undefined-server-variable.