schema-enum-no-duplicates
Since 0.9.0 · fixed by --fix · In the rulesets: Recommended at error, Strict at error, All at error
This rule ensures that the enum lists of schema objects contain no
duplicate values.
Rule details
Duplicate enum values carry no information, and usually indicate a typo or a merge mistake (for example, a value that was meant to be different).
The schema-enum-no-duplicates rule checks the enum list of every schema of
an AsyncAPI document, and reports Duplicate enum value once for every value
that repeats an earlier value of the same list. Values of any type are
compared, including numbers, objects and arrays.
Examples
Good.
asyncapi: 3.0.0
info:
title: Pet Events
version: 1.0.0
components:
schemas:
PetStatus:
type: string
enum: [AVAILABLE, ADOPTED, RETURNED]
Bad.
asyncapi: 3.0.0
info:
title: Pet Events
version: 1.0.0
components:
schemas:
PetStatus:
type: string
enum: [AVAILABLE, ADOPTED, AVAILABLE]
Automatic fixes
--fix removes the duplicate values, keeping the
first occurrence of each value.
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.asyncapi has the details.
commands:
lint:
asyncapi:
rules:
schema-enum-no-duplicates: off