Linter rulesAsyncAPItags-unique
tags-unique
Since 0.9.0 · fixed by --fix
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.
Configuration
None.
Examples
Good.
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.
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
When invoked with --fix, this rule removes redundant duplicates:
- a duplicate that contains only a
nameis removed; if the earlier tag contains only anameand 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.
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.