# operation-tags-defined

Source: https://apigenie.pl/docs/linter/swagger/rules/operation-tags-defined

This rule checks whether every operation of a Swagger 2.0 document has at
least one tag.

## Rule Details

Tags group operations. Documentation tools use them to build sections, and code
generators use them to split generated clients into classes or modules.
Untagged operations usually end up in a catch-all group.

The `operation-tags-defined` rule reports `Operation has no tags defined` for
every operation whose `tags` list is missing or empty.

## Configuration

None.

## Examples

**Good**. The operation is tagged.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
tags:
  - name: pets
    description: Operations on pets.
paths:
  /pets:
    get:
      tags: [pets]
      responses:
        '200':
          description: A list of pets.
```

**Bad**. The first operation has no tags, the second has an empty list.

```yaml
swagger: '2.0'
info:
  title: Pet Store
  version: 1.0.0
paths:
  /pets:
    get:
      responses:
        '200':
          description: A list of pets.
    post:
      tags: []
      responses:
        '201':
          description: The pet was added.
```

## When Not to Use It

You may disable this rule for small APIs where grouping operations brings no
value.

## Compatibility

This rule is compatible with Swagger 2.0 documents. OpenAPI 3.x documents are
linted by the OpenAPI linter, which has a rule of the same name.
