schema-enum-no-duplicates

Since 0.0.1 · In the rulesets: Recommended at error, Strict at error, All at error

This rule checks that no value appears twice in an enum.

Rule details

A repeated value is a copy-and-paste mistake, often of a value that was meant to be another one: active, active where active, archived was intended. Generated code for the enum then has one member fewer than the API has values, or does not compile.

The rule reports Duplicate enum value on the schema.

Examples

Good.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - active
        - inactive

Bad. active twice.

components:
  schemas:
    UserStatus:
      type: string
      enum:
        - active
        - active

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.

commands:
  lint:
    rules:
      schema-enum-no-duplicates: off
Was this helpful?