# schema-enum-no-duplicates

Source: https://api-genie.dev/docs/linter/asyncapi/rules/schema-enum-no-duplicates

A rule of the AsyncAPI linter, which reads AsyncAPI 3 documents; the reader rejects AsyncAPI 2 documents. 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**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
components:
  schemas:
    PetStatus:
      type: string
      enum: [AVAILABLE, ADOPTED, RETURNED]
```

**Bad**.

```yaml
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.
