# tags-unique

Source: https://api-genie.dev/docs/linter/asyncapi/rules/tags-unique

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 warning, Strict at error, All at error.

This rule checks whether the names of the tags listed in `info.tags` are
unique.

## Rule details

Duplicate tags are confusing: documentation generators may render the same
section twice, or merge the tags in an unpredictable way.

The `tags-unique` rule checks the `info.tags` list of an AsyncAPI document,
and reports `Tag name is not unique (<name>)` for every tag whose name
repeats the name of another tag in the list. Names are compared
case-insensitively, so `Pets` and `pets` are duplicates. Tags of operations,
messages and other objects are not checked.

## Examples

**Good**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  tags:
    - name: adoption
      description: Events related to adopting and returning pets.
    - name: inventory
      description: Events related to the shelter inventory.
```

**Bad**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
  tags:
    - name: adoption
      description: Events related to adopting and returning pets.
    - name: Adoption
```

## Automatic fixes

`--fix` removes redundant duplicates:

- a duplicate that contains only a `name` is removed; if the earlier tag
  contains only a `name` and the later one has more content, the earlier tag
  is removed instead,
- a duplicate whose content (apart from the `name`) is identical to the
  earlier tag is removed.

Duplicates that differ in their descriptions or other properties are reported
but not fixed, as the rule cannot tell which one is correct. In the "Bad"
example above, the second tag is removed.
