# operation-tags-defined

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

A rule of the AsyncAPI linter, which reads AsyncAPI 3 documents; the reader rejects AsyncAPI 2 documents. Since 0.9.0. In the rulesets: Recommended at warning, Strict at warning, All at error.

This rule checks whether every operation of an AsyncAPI document has at least
one tag assigned.

## Rule details

Tags group related operations. Documentation generators use them to organize
operations into sections, and consumers use them to find the operations they
are interested in.

The `operation-tags-defined` rule reports `Operation has no tags defined` for
every operation (in the root `operations` map and in `components/operations`)
whose own `tags` list is missing or empty. Tags coming from operation traits
are not taken into account.

Turn the rule off for small APIs, whose operations do not need to be grouped.

## Examples

**Good**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
channels:
  petAdopted:
    address: pets.adopted
operations:
  onPetAdopted:
    action: receive
    channel:
      $ref: "#/channels/petAdopted"
    tags:
      - name: adoption
```

**Bad**.

```yaml
asyncapi: 3.0.0
info:
  title: Pet Events
  version: 1.0.0
channels:
  petAdopted:
    address: pets.adopted
operations:
  onPetAdopted:
    action: receive
    channel:
      $ref: "#/channels/petAdopted"
```
