no-duplicate-enum-values
Finds repeated values in a schema's enum array.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Platinum |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient–Strict | Warning |
| Complete | Error |
Intent
Duplicate members add noise, can produce duplicate generated constants, and communicate no additional valid state.
Flags
Every occurrence of an enum value after its first appearance. Values are compared by their JSON representation, so type remains significant.
Does not flag
The first occurrence of a value or an enum whose members are unique.
See it fail
Status:
type: string
enum: [active, pending, active]
The second active entry is reported.
Fix it
Status:
type: string
enum: [active, pending]
Configure
profiles:
default:
rules:
extends: [recommended]
override:
no-duplicate-enum-values: error
Nearby: enum-value-schema-mismatch, enum-no-matching-values.