Skip to content

Commit 6c528f2

Browse files
committed
chore: add rules docs
1 parent 05cb768 commit 6c528f2

35 files changed

+1325
-240
lines changed

.changeset/new-falcons-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@redocly/openapi-core": patch
3+
---
4+
5+
Removed the `no-actions-type-end` Spot rule.

docs/guides/lint-arazzo.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,7 @@ run `redocly lint --generate-ignore-file` to add all problems to the ignore file
7171
## Configure the linting rules
7272

7373
Choose from the ready-made rulesets (`minimal`, `recommended` or `recommended-strict`), or go one better and configure the rules that suit your use case.
74-
The rules available for linting Arazzo are:
75-
76-
- `parameters-not-in-body`: the `in` section inside `parameters` must not contain a `body`.
77-
- `sourceDescription-type`: the `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.
78-
- `version-enum`: the `version` property must be one of the supported values.
79-
- `workflowId-unique`: the `workflowId` property must be unique across all workflows.
80-
- `stepId-unique`: the `stepId` must be unique amongst all steps described in the workflow.
81-
- `sourceDescription-name-unique`: the `name` property of the `sourceDescription` object must be unique across all source descriptions.
82-
- `workflow-dependsOn`: the items in the `workflow` `dependsOn` property must exist and be unique.
83-
- `parameters-unique`: the `parameters` list must not include duplicate parameters.
84-
- `step-onSuccess-unique`: the `onSuccess` actions of the `step` object must be unique.
85-
- `step-onFailure-unique`: the `onFailure` actions of the `step` object must be unique.
86-
- `requestBody-replacements-unique`: the `replacements` of the `requestBody` object must be unique.
87-
- `no-criteria-xpath`: the `xpath` type criteria is not supported by Spot.
88-
- `no-actions-type-end`: the `end` type action is not supported by Spot.
89-
- `criteria-unique`: the criteria list must not contain duplicated assertions.
74+
There's a full [list of built-in rules for Arazzo](../rules/built-in-rules.md#arazzo-rules) to refer to.
9075

9176
Add the rules to `redocly.yaml`, but for Arazzo specifications, the rules go in their own configuration section called `arazzoRules`.
9277
The following example shows configuration for the minimal ruleset with some additional rules configuration:

docs/guides/lint-asyncapi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ some of the built-in rules. The currently-supported rules are:
5353

5454
- `info-contact`: the `Info` section must contain a valid `Contact` field.
5555
- `operation-operationId`: every operation must have a valid `operationId`.
56-
- `channels-kebab-case`: channel names should be `kebab-case` (lowercase with hyphens).
57-
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their names.
56+
- `channels-kebab-case`: channel address should be `kebab-case` (lowercase with hyphens).
57+
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their address.
5858
- `tag-description`: all tags require a description.
5959
- `tags-alphabetical`: tags should be listed in the AsyncAPI file in alphabetical order.
6060

docs/rules/arazzo/criteria-unique.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
slug: /docs/cli/rules/arazzo/criteria-unique
3-
---
4-
51
# criteria-unique
62

73
The criteria list must not contain duplicated assertions.
@@ -10,9 +6,9 @@ The criteria list must not contain duplicated assertions.
106
| ------ | ------------- |
117
| 1.0.0 ||
128

13-
## API design principles
9+
## Design principles
1410

15-
The criteria list must not contain duplicated assertions.
11+
To avoid redundancy and confusion, the assertions in the criteria list must not be duplicated.
1612

1713
## Configuration
1814

@@ -23,7 +19,7 @@ The criteria list must not contain duplicated assertions.
2319
An example configuration:
2420

2521
```yaml
26-
arazzoRules:
22+
rules:
2723
criteria-unique: error
2824
```
2925
@@ -32,7 +28,7 @@ arazzoRules:
3228
Given the following configuration:
3329
3430
```yaml
35-
arazzoRules:
31+
rules:
3632
criteria-unique: error
3733
```
3834
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# parameters-unique
2+
3+
Requires unique values in the `parameters` lists.
4+
5+
| Arazzo | Compatibility |
6+
| ------ | ------------- |
7+
| 1.0.0 ||
8+
9+
## Design principles
10+
11+
A list of `parameters` that are applicable to a step or all the steps described in a workflow must not contain duplicates.
12+
If duplicates are present, unexpected parameter overrides could cause problems.
13+
14+
This ruled checks parameter lists in the following locations:
15+
16+
- `workflows.[workflow].parameters`
17+
- `workflows.[workflow[.steps.[step].parameters`
18+
- `x-parameters`
19+
20+
## Configuration
21+
22+
| Option | Type | Description |
23+
| -------- | ------ | ------------------------------------------------------- |
24+
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |
25+
26+
An example configuration:
27+
28+
```yaml
29+
rules:
30+
parameters-unique: error
31+
```
32+
33+
## Examples
34+
35+
Given the following configuration:
36+
37+
```yaml
38+
rules:
39+
parameters-unique: error
40+
```
41+
42+
Example of a **correct** `parameters` list:
43+
44+
```yaml Correct example
45+
workflows:
46+
- workflowId: get-museum-hours
47+
parameters:
48+
- in: header
49+
name: Authorization
50+
value: Basic Og==
51+
- in: header
52+
name: X-Forwarded-For
53+
value: 1.2.3.4
54+
```
55+
56+
## Resources
57+
58+
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/parameters-unique.ts)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# requestBody-replacements-unique
2+
3+
Requires the `replacements` in the `step.requestBody` object to be unique.
4+
5+
| Arazzo | Compatibility |
6+
| ------ | ------------- |
7+
| 1.0.0 ||
8+
9+
## Design principles
10+
11+
The list of locations and values to set within a payload must not have duplicates that might result in content override.
12+
13+
## Configuration
14+
15+
| Option | Type | Description |
16+
| -------- | ------ | ------------------------------------------------------- |
17+
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |
18+
19+
An example configuration:
20+
21+
```yaml
22+
rules:
23+
requestBody-replacements-unique: error
24+
```
25+
26+
## Examples
27+
28+
Given the following configuration:
29+
30+
```yaml
31+
rules:
32+
requestBody-replacements-unique: error
33+
```
34+
35+
Example of a **correct** `replacements` list:
36+
37+
```yaml Correct example
38+
workflows:
39+
- workflowId: events-crud
40+
steps:
41+
- stepId: create-event
42+
operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/post
43+
requestBody:
44+
payload:
45+
name: 'Mermaid Treasure Identification and Analysis'
46+
description: 'Identify and analyze mermaid treasures'
47+
replacements:
48+
- target: name
49+
value: 'new name'
50+
- target: description
51+
value: 'another description'
52+
```
53+
54+
## Resources
55+
56+
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/requestBody-replacements-unique.ts)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# sourceDescriptions-name-unique
2+
3+
The `name` property of the Source Description object must be unique across all source descriptions.
4+
5+
| Arazzo | Compatibility |
6+
| ------ | ------------- |
7+
| 1.0.0 ||
8+
9+
## Design principles
10+
11+
To avoid confusion or unexpected outputs, each Source Description object must have a unique `name` property.
12+
Especially in a longer list of sources, this could be difficult to identify and could have unwanted side effects.
13+
14+
## Configuration
15+
16+
| Option | Type | Description |
17+
| -------- | ------ | ------------------------------------------------------- |
18+
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |
19+
20+
An example configuration:
21+
22+
```yaml
23+
rules:
24+
sourceDescriptions-name-unique: error
25+
```
26+
27+
## Examples
28+
29+
Given the following configuration:
30+
31+
```yaml
32+
rules:
33+
sourceDescriptions-name-unique: error
34+
```
35+
36+
Example of a **correct** `sourceDescriptions` list:
37+
38+
```yaml Correct example
39+
sourceDescriptions:
40+
- name: museum-api
41+
type: openapi
42+
url: ../openapi.yaml
43+
- name: pets-api
44+
type: openapi
45+
url: ../petstore.yaml
46+
```
47+
48+
## Related rules
49+
50+
- [sourceDescription-type](./sourceDescriptions-type.md)
51+
52+
## Resources
53+
54+
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/sourceDescriptions-name-unique.ts)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# sourceDescriptions-not-empty
2+
3+
The Source Description must have at least one entry.
4+
5+
| Arazzo | Compatibility |
6+
| ------ | ------------- |
7+
| 1.0.0 ||
8+
9+
## Design principles
10+
11+
Source descriptions are an important part of an Arazzo description, and at least one entry must exist.
12+
If the list is empty, this could indicate an omission or another problem; this rule alerts you if that happens.
13+
14+
## Configuration
15+
16+
| Option | Type | Description |
17+
| -------- | ------ | ------------------------------------------------------- |
18+
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |
19+
20+
An example configuration:
21+
22+
```yaml
23+
rules:
24+
sourceDescriptions-not-empty: error
25+
```
26+
27+
## Examples
28+
29+
Given the following configuration:
30+
31+
```yaml
32+
rules:
33+
sourceDescriptions-not-empty: error
34+
```
35+
36+
Example of a **correct** usage:
37+
38+
```yaml Correct example
39+
arazzo: '1.0.0'
40+
info:
41+
title: Cool API
42+
version: 1.0.0
43+
description: A cool API
44+
sourceDescriptions:
45+
- name: museum-api
46+
type: openapi
47+
url: openapi.yaml
48+
- name: another-api
49+
type: openapi
50+
url: openapi.yaml
51+
workflows:
52+
- workflowId: get-museum-hours
53+
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
54+
parameters:
55+
- in: header
56+
name: Authorization
57+
value: Basic Og==
58+
steps:
59+
- stepId: get-museum-hours
60+
description: >-
61+
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
62+
operationId: $sourceDescriptions.museum-api.getMuseumHours
63+
successCriteria:
64+
- condition: $statusCode == 200
65+
```
66+
67+
## Resources
68+
69+
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/sourceDescriptions-not-empty.ts)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# sourceDescriptions-type
2+
3+
The `type` property of the Source Description object must be either `openapi` or `arazzo`.
4+
5+
| Arazzo | Compatibility |
6+
| ------ | ------------- |
7+
| 1.0.0 ||
8+
9+
## Design principles
10+
11+
Arazzo currently supports either an OpenAPI file or another Arazzo file as the source description.
12+
This rule makes sure that the type is clearly identified and is one of the supported types.
13+
14+
## Configuration
15+
16+
| Option | Type | Description |
17+
| -------- | ------ | ------------------------------------------------------- |
18+
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |
19+
20+
An example configuration:
21+
22+
```yaml
23+
rules:
24+
sourceDescriptions-type: error
25+
```
26+
27+
## Examples
28+
29+
Given the following configuration:
30+
31+
```yaml
32+
rules:
33+
sourceDescriptions-type: error
34+
```
35+
36+
Example of a **correct** `sourceDescriptions` list:
37+
38+
```yaml Correct example
39+
sourceDescriptions:
40+
- name: museum-api
41+
type: openapi
42+
url: ../openapi.yaml
43+
- name: tickets-from-museum-api
44+
type: arazzo
45+
url: museum-tickets.arazzo.yaml
46+
```
47+
48+
## Related rules
49+
50+
- [sourceDescription-name-unique](./sourceDescriptions-name-unique.md)
51+
52+
## Resources
53+
54+
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/sourceDescription-type.ts)

0 commit comments

Comments
 (0)