enum-no-matching-values
Finds an enum where none of its non-null values satisfy the declared schema.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Platinum |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient | Warning |
| Recommended–Complete | Error |
Intent
An enum must offer at least one usable value. Otherwise, the schema cannot describe a non-null instance.
Flags
An enum with at least one non-null value when every non-null value conflicts with the schema's declared type and constraints.
Does not flag
An enum with any matching non-null value, a null-only enum, or a schema without a declared non-null type.
See it fail
Priority:
type: integer
minimum: 1
enum: [low, high]
Diagnostic: No enum value matches the declared schema
Fix it
Make the values agree with the schema:
Priority:
type: integer
minimum: 1
enum: [1, 2]
Configure
profiles:
default:
rules:
extends: [recommended]
override:
enum-no-matching-values: warn
Nearby: enum-value-schema-mismatch, no-enum-type-mismatch.