# schema-enum-no-duplicates

Source: https://apigenie.pl/docs/linter/asyncapi/rules/schema-enum-no-duplicates

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.

## Configuration

None.

## 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

When invoked with `--fix`, this rule removes the duplicate values, keeping the
first occurrence of each value.

## When Not to Use It

We recommend to always enable this rule.

## Compatibility

This rule is compatible with AsyncAPI 3.x documents. AsyncAPI 2.x documents
are rejected by the reader and are not linted.
