Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1e86a98
feat: add tags duplicated names
AlbinaBlazhko17 Jul 1, 2025
93835ab
chore: remove getTagName function and import it from utils
AlbinaBlazhko17 Jul 1, 2025
28a7ffc
feat: improve for loop
AlbinaBlazhko17 Jul 1, 2025
5c9106e
feat: add tests
AlbinaBlazhko17 Jul 1, 2025
8fce0ad
feat: add rule to the configs
AlbinaBlazhko17 Jul 1, 2025
5d74e8c
fix: spelling inside all config
AlbinaBlazhko17 Jul 1, 2025
902f7e2
fix: global tests and regenerate snapshot
AlbinaBlazhko17 Jul 1, 2025
3408cca
chore: add docs
AlbinaBlazhko17 Jul 1, 2025
34c09eb
feat: add changelog
AlbinaBlazhko17 Jul 1, 2025
6516b26
chore: remove testing file
AlbinaBlazhko17 Jul 1, 2025
11ced3f
fix: change inside docs default behavior from error to warn
AlbinaBlazhko17 Jul 1, 2025
cdf1278
fix: change inside snapshot error to warning
AlbinaBlazhko17 Jul 1, 2025
54ee6af
feat: add async types
AlbinaBlazhko17 Jul 1, 2025
4bea4f3
feat: add docs for the async api
AlbinaBlazhko17 Jul 1, 2025
04b1f75
chore: remove related rules error
AlbinaBlazhko17 Jul 1, 2025
098c090
chore: change changeset sentence
AlbinaBlazhko17 Jul 1, 2025
b94ddea
feat: change function structure to validate schema
AlbinaBlazhko17 Jul 1, 2025
cb5bc3a
fix: e2e test
AlbinaBlazhko17 Jul 1, 2025
ea51c42
Apply suggestions from code review
JLekawa Jul 1, 2025
a59bc10
chore: rename rule from tags-duplicated-names to no-duplicated-tag-names
AlbinaBlazhko17 Jul 6, 2025
9e5de60
chore: change changelog version from major to minor
AlbinaBlazhko17 Jul 6, 2025
c54bba0
feat: add inside changelog @redocly/cli version
AlbinaBlazhko17 Jul 6, 2025
1c36cb3
chore: change naming of the test
AlbinaBlazhko17 Jul 6, 2025
0bd01b4
fix: tests for the new rule
AlbinaBlazhko17 Jul 6, 2025
590c07d
fix: remove root tags check and add proper location without child
AlbinaBlazhko17 Jul 6, 2025
a9c336b
chore: rename e2e test folder for new rule and update snapshot
AlbinaBlazhko17 Jul 6, 2025
42a43be
chore: remove minus symbol in changeset
AlbinaBlazhko17 Jul 7, 2025
8b11a24
Apply suggestions from code review
JLekawa Jul 8, 2025
8e6aa00
chore: add dot in the end of the report message
AlbinaBlazhko17 Jul 8, 2025
ad9ee38
chore: update snapshots
AlbinaBlazhko17 Jul 8, 2025
21bf108
chore: update snapshot
AlbinaBlazhko17 Jul 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/orange-ghosts-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@redocly/openapi-core": minor
"@redocly/cli": minor
---

Added the `no-duplicated-tag-names` rule to check for duplications in the `tags` field in API descriptions.
33 changes: 33 additions & 0 deletions __tests__/lint/no-duplicated-tag-names/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
openapi: 3.0.2
info:
title: No Duplicated Tag Names Test
version: '1.0.0'
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: store
description: YOU DO NOT SEE THIS
paths:
/pet:
get:
summary: Get a pet
operationId: getPet
responses:
'200':
description: OK
/store:
get:
summary: Get store info
operationId: getStore
responses:
'200':
description: OK
/store2:
get:
summary: Get store info 2
operationId: getStore2
responses:
'200':
description: OK
6 changes: 6 additions & 0 deletions __tests__/lint/no-duplicated-tag-names/redocly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apis:
main:
root: ./openapi.yaml

rules:
no-duplicated-tag-names: warn
23 changes: 23 additions & 0 deletions __tests__/lint/no-duplicated-tag-names/snapshot.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[1] openapi.yaml:10:5 at #/tags/2

Duplicate tag name found: 'store'.

8 | - name: store
9 | description: Access to Petstore orders
10 | - name: store
| ^^^^^^^^^^^
11 | description: YOU DO NOT SEE THIS
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 | paths:
13 | /pet:

Warning was generated by the no-duplicated-tag-names rule.



validating openapi.yaml...
openapi.yaml: validated in <test>ms

Woohoo! Your API description is valid. 🎉
You have 1 warning.

89 changes: 89 additions & 0 deletions docs/@v2/rules/async/no-duplicated-tag-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# no-duplicated-tag-names

Ensures that tag names in the `tags` array are unique.
This rule prevents duplication of tag names which could lead to inconsistent API documentation.

| AsyncAPI | Compatibility |
| -------- | ------------- |
| 2.6 | ✅ |
| 3.0 | ✅ |

## API design principles

Tags are used to group operations in AsyncAPI specifications.
Create unique tags to clearly categorize operations.
Having duplicate tags can cause confusion in documentation rendering tools, makes the specification harder to maintain,
and may lead to operations being grouped incorrectly.

## Configuration

| Option | Type | Description |
| ---------- | ------- | ----------------------------------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `warn`. |
| ignoreCase | boolean | Possible values: `true`, `false`. Default `false` (in `recommended` configuration). |

An example configuration:

```yaml
rules:
no-duplicated-tag-names: error
```

Configuration that ignores case:

```yaml
rules:
no-duplicated-tag-names:
severity: error
ignoreCase: true
```

## Examples

Given this configuration:

```yaml
rules:
no-duplicated-tag-names: error
```

Example of **incorrect** tags:

```yaml Bad example
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: store
description: Duplicated store tag
```

Example of **correct** tags:

```yaml Good example
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: user
description: Operations about user
```

With `ignoreCase: true`, this would also be incorrect:

```yaml
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: Store
description: Case-sensitive duplicate
```

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/common/no-duplicated-tag-names.ts)
- [Tags docs](https://redocly.com/docs/openapi-visual-reference/tags/)
98 changes: 98 additions & 0 deletions docs/@v2/rules/oas/no-duplicated-tag-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
slug: /docs/cli/v2/rules/oas/no-duplicated-tag-names
---

# no-duplicated-tag-names

Ensures that tag names in the `tags` array are unique.
This rule prevents duplication of tag names which could lead to inconsistent API documentation.

| OAS | Compatibility |
| --- | ------------- |
| 2.0 | ✅ |
| 3.0 | ✅ |
| 3.1 | ✅ |

## API design principles

Tags are used to group operations in OpenAPI specifications.
Create unique tags to clearly categorize operations.
Having duplicate tags can cause confusion in documentation rendering tools, makes the specification harder to maintain,
and may lead to operations being grouped incorrectly.

## Configuration

| Option | Type | Description |
| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `warn` (in `recommended` configuration). |
| ignoreCase | boolean | Possible values: `true`, `false`. Default `false` (in `recommended` configuration). Set to `true` to treat tags with different casing as duplicates (e.g., "Pet" and "pet"). |

An example configuration:

```yaml
rules:
no-duplicated-tag-names: error
```

Configuration that ignores case:

```yaml
rules:
no-duplicated-tag-names:
severity: error
ignoreCase: true
```

## Examples

Given this configuration:

```yaml
rules:
no-duplicated-tag-names: error
```

Example of **incorrect** tags:

```yaml Bad example
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: store
description: Duplicated store tag
```

Example of **correct** tags:

```yaml Good example
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: user
description: Operations about user
```

With `ignoreCase: true`, this would also be incorrect:

```yaml
tags:
- name: pet
description: Everything about your Pets
- name: store
description: Access to Petstore orders
- name: Store
description: Case-sensitive duplicate
```

## Related rules

- [tag-description](./tag-description.md)

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/common/no-duplicated-tag-names.ts)
- [Tags docs](https://redocly.com/docs/openapi-visual-reference/tags/)
10 changes: 10 additions & 0 deletions docs/@v2/rules/ruleset-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ rules:
response-contains-property: off
response-mime-type: off
array-parameter-serialization: off
no-duplicated-tag-names: off
```

### Minimal ruleset: OpenAPI 3.0
Expand Down Expand Up @@ -136,6 +137,7 @@ rules:
response-contains-property: off
response-mime-type: off
array-parameter-serialization: off
no-duplicated-tag-names: off
```

### Minimal ruleset: OpenAPI 2.0
Expand Down Expand Up @@ -186,6 +188,7 @@ rules:
request-mime-type: off
response-contains-property: off
response-mime-type: off
no-duplicated-tag-names: off
```

### Minimal ruleset: AsyncAPI 3.0
Expand All @@ -200,6 +203,7 @@ rules:
tags-alphabetical: off
channels-kebab-case: off
no-channel-trailing-slash: off
no-duplicated-tag-names: off
```

### Minimal ruleset: AsyncAPI 2.6
Expand All @@ -214,6 +218,7 @@ rules:
tags-alphabetical: off
channels-kebab-case: off
no-channel-trailing-slash: off
no-duplicated-tag-names: off
```

### Minimal ruleset: Arazzo 1.0
Expand Down Expand Up @@ -346,6 +351,7 @@ oas3_1Rules:
response-contains-property: off
response-mime-type: off
array-parameter-serialization: off
no-duplicated-tag-names: warn
```

### Recommended ruleset: OpenAPI 3.0
Expand Down Expand Up @@ -408,6 +414,7 @@ rules:
response-contains-property: off
response-mime-type: off
array-parameter-serialization: off
no-duplicated-tag-names: warn
```

### Recommended ruleset: OpenAPI 2.0
Expand Down Expand Up @@ -458,6 +465,7 @@ rules:
request-mime-type: off
response-contains-property: off
response-mime-type: off
no-duplicated-tag-names: warn
```

### Recommended ruleset: AsyncAPI 3.0
Expand All @@ -472,6 +480,7 @@ rules:
tags-alphabetical: off
channels-kebab-case: off
no-channel-trailing-slash: off
no-duplicated-tag-names: warn
```

### Recommended ruleset: AsyncAPI 2.6
Expand All @@ -486,6 +495,7 @@ rules:
tags-alphabetical: off
channels-kebab-case: off
no-channel-trailing-slash: off
no-duplicated-tag-names: warn
```

### Recommended ruleset: Arazzo 1.0
Expand Down
Loading
Loading