Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add arazzo rules documentation #1697

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cdb9222
chore: add arazzo rules documentation
DmitryAnansky Aug 29, 2024
c4de777
chore: add arazzo rules documentation
DmitryAnansky Aug 29, 2024
ba802b9
chore: document requestBody-replacements-unique rule
DmitryAnansky Aug 29, 2024
09d0016
chore: document arazzo rules
DmitryAnansky Aug 30, 2024
c59483d
chore: document async rules
DmitryAnansky Aug 30, 2024
fb35ae1
chore: update links
DmitryAnansky Aug 30, 2024
866978a
Apply suggestions from code review
lornajane Sep 5, 2024
7b024e6
docs: copyedit, remove diagrams and page slugs, update for accuracy
lornajane Sep 5, 2024
f83e4c0
docs: add new rules to built-in rules page, add format grouping
lornajane Oct 4, 2024
85f99fd
docs: expand on the rules configuration options for basic/configured/…
lornajane Oct 4, 2024
f8a7bc2
docs: add descriptions and sorting to the new format rules
lornajane Oct 4, 2024
988785a
docs: Split rules config to separate page, add missing rules to list,…
lornajane Oct 4, 2024
5cf1a58
docs: add copy/paste versions of ruleset configurations for each api …
lornajane Oct 4, 2024
5ca82e9
docs: fix a renamed rule and a stray ARAZZO label
lornajane Oct 4, 2024
8478eac
docs: run prettier
lornajane Oct 4, 2024
9d18cb7
docs: adjust rule example to be more obvious
lornajane Oct 7, 2024
ce5d903
docs: update link
lornajane Oct 7, 2024
3074a89
docs: update AsyncAPI channel rules with more info, add all rules to …
lornajane Oct 7, 2024
baaf09b
Apply suggestions from code review
lornajane Oct 8, 2024
00c91c0
docs: remove mentions of the per-format rule configuration feature un…
lornajane Oct 17, 2024
b3f89f3
chore: add sourceDescriptions-not-empty rule docs
DmitryAnansky Oct 18, 2024
47a7701
docs: Adjust design principles sections of Arazzo rules
lornajane Oct 25, 2024
91b04e4
docs: Make vale happy
lornajane Oct 25, 2024
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
19 changes: 2 additions & 17 deletions docs/guides/lint-arazzo.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,7 @@ run `redocly lint --generate-ignore-file` to add all problems to the ignore file
## Configure the linting rules

Choose from the ready-made rulesets (`minimal`, `recommended` or `recommended-strict`), or go one better and configure the rules that suit your use case.
The rules available for linting Arazzo are:

- `parameters-not-in-body`: the `in` section inside `parameters` must not contain a `body`.
- `sourceDescription-type`: the `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.
- `version-enum`: the `version` property must be one of the supported values.
- `workflowId-unique`: the `workflowId` property must be unique across all workflows.
- `stepId-unique`: the `stepId` must be unique amongst all steps described in the workflow.
- `sourceDescription-name-unique`: the `name` property of the `sourceDescription` object must be unique across all source descriptions.
- `workflow-dependsOn`: the items in the `workflow` `dependsOn` property must exist and be unique.
- `parameters-unique`: the `parameters` list must not include duplicate parameters.
- `step-onSuccess-unique`: the `onSuccess` actions of the `step` object must be unique.
- `step-onFailure-unique`: the `onFailure` actions of the `step` object must be unique.
- `requestBody-replacements-unique`: the `replacements` of the `requestBody` object must be unique.
- `no-criteria-xpath`: the `xpath` type criteria is not supported by Spot.
- `no-actions-type-end`: the `end` type action is not supported by Spot.
- `criteria-unique`: the criteria list must not contain duplicated assertions.
There's a full [list of built-in rules for Arazzo](../rules/built-in-rules.md#arazzo-rules) to refer to.

Add the rules to `redocly.yaml`, but for Arazzo specifications, the rules go in their own configuration section called `arazzoRules`.
The following example shows configuration for the minimal ruleset with some additional rules configuration:
Expand All @@ -96,7 +81,7 @@ extends:
- minimal

arazzoRules:
sourceDescription-name-unique: warn
sourceDescriptions-name-unique: warn
version-enum: error
```

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/lint-asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ some of the built-in rules. The currently-supported rules are:

- `info-contact`: the `Info` section must contain a valid `Contact` field.
- `operation-operationId`: every operation must have a valid `operationId`.
- `channels-kebab-case`: channel names should be `kebab-case` (lowercase with hyphens).
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their names.
- `channels-kebab-case`: channel address should be `kebab-case` (lowercase with hyphens).
lornajane marked this conversation as resolved.
Show resolved Hide resolved
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their address.
lornajane marked this conversation as resolved.
Show resolved Hide resolved
- `tag-description`: all tags require a description.
- `tags-alphabetical`: tags should be listed in the AsyncAPI file in alphabetical order.

Expand Down
4 changes: 0 additions & 4 deletions docs/rules/arazzo/criteria-unique.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
slug: /docs/cli/rules/arazzo/criteria-unique
---

# criteria-unique

The criteria list must not contain duplicated assertions.
Expand Down
72 changes: 72 additions & 0 deletions docs/rules/arazzo/parameters-unique.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# parameters-unique

Requires unique values in the `parameters` lists.

| Arazzo | Compatibility |
| ------ | ------------- |
| 1.0.0 | ✅ |

## API design principles
lornajane marked this conversation as resolved.
Show resolved Hide resolved

A list of `parameters` that are applicable to a step or all the steps described in a workflow should not contain duplicates.
If duplicates are present, unexpected parameter overrides could cause problems.

Checks parameter lists in the following locations:

- `workflows.[workflow].parameters`
- `workflows.[workflow[.steps.[step].parameters`
- `x-parameters`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A list of `parameters` that are applicable to a step or all the steps described in a workflow should not contain duplicates.
If duplicates are present, unexpected parameter overrides could cause problems.
Checks parameter lists in the following locations:
- `workflows.[workflow].parameters`
- `workflows.[workflow[.steps.[step].parameters`
- `x-parameters`
The `parameters` list for any step (or across all steps) in a workflow should not contain duplicate values. Duplicates can lead to unexpected parameter overrides, causing potential issues in the workflow execution.


## Configuration

| Option | Type | Description |
| -------- | ------ | ------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |

An example configuration:

```yaml
arazzoRules:
parameters-unique: error
```

## Examples

Given the following configuration:

```yaml
arazzoRules:
parameters-unique: error
```

Example of an **incorrect** parameters array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
workflows:
- workflowId: get-museum-hours
parameters:
- in: header
name: Authorization
value: Main Og==
- in: header
name: Authorization
value: Basic Og==
```

Example of a **correct** parameters array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
workflows:
- workflowId: get-museum-hours
parameters:
- in: header
name: Authorization
value: Basic Og==
- in: header
name: X-Forwarded-For
value: 1.2.3.4
```

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/parameters-unique.ts)
75 changes: 75 additions & 0 deletions docs/rules/arazzo/requestBody-replacements-unique.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# requestBody-replacements-unique

Requires the `replacements` in the `step.requestBody` object to be unique.

| Arazzo | Compatibility |
| ------ | ------------- |
| 1.0.0 | ✅ |

## API design principles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## API design principles
## Rationale


The list of locations and values to set within a payload must not have duplicates that might result in content override.

## Configuration

| Option | Type | Description |
| -------- | ------ | ------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |

An example configuration:

```yaml
arazzoRules:
requestBody-replacements-unique: error
```

## Examples

Given the following configuration:

```yaml
arazzoRules:
requestBody-replacements-unique: error
```

Example of an **incorrect** replacements array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
workflows:
- workflowId: events-crud
steps:
- stepId: create-event
operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/post
requestBody:
payload:
name: 'Mermaid Treasure Identification and Analysis'
description: 'Identify and analyze mermaid treasures'
replacements:
- target: name
value: 'new name'
- target: name
value: 'another name'
Comment on lines +48 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is invalid not because of duplicate targets, but because targets must be JSON Pointer or XPath. This is not.

Suggested change
- target: name
value: 'new name'
- target: name
value: 'another name'
- target: /name
value: 'new name'
- target: /name
value: 'another name'

```

Example of a **correct** replacements array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
workflows:
- workflowId: events-crud
steps:
- stepId: create-event
operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/post
requestBody:
payload:
name: 'Mermaid Treasure Identification and Analysis'
description: 'Identify and analyze mermaid treasures'
replacements:
- target: name
value: 'new name'
- target: description
value: 'another description'
Comment on lines +67 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- target: name
value: 'new name'
- target: description
value: 'another description'
- target: /name
value: 'new name'
- target: /description
value: 'another description'

```

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/requestBody-replacements-unique.ts)
65 changes: 65 additions & 0 deletions docs/rules/arazzo/sourceDescriptions-name-unique.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# sourceDescription-name-unique
lornajane marked this conversation as resolved.
Show resolved Hide resolved

Requires the `name` property of the `sourceDescription` object must be unique across all source descriptions.
lornajane marked this conversation as resolved.
Show resolved Hide resolved

| Arazzo | Compatibility |
| ------ | ------------- |
| 1.0.0 | ✅ |

## API design principles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## API design principles
## Rationale


To avoid confusion or unexpected outputs, each `sourceDescription` object should have a unique `name` property.
lornajane marked this conversation as resolved.
Show resolved Hide resolved

## Configuration

| Option | Type | Description |
| -------- | ------ | ------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |

An example configuration:

```yaml
arazzoRules:
sourceDescription-name-unique: error
lornajane marked this conversation as resolved.
Show resolved Hide resolved
```

## Examples

Given the following configuration:

```yaml
arazzoRules:
sourceDescription-name-unique: error
lornajane marked this conversation as resolved.
Show resolved Hide resolved
```

Example of an **incorrect** sourceDescriptions array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
sourceDescriptions:
- name: museum-api
type: openapi
url: ../openapi.yaml
- name: museum-api
type: openapi
url: ../petstore.yaml
```

Example of a **correct** sourceDescriptions array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
sourceDescriptions:
- name: museum-api
type: openapi
url: ../openapi.yaml
- name: pets-api
type: openapi
url: ../petstore.yaml
```

## Related rules

- [sourceDescription-type](./sourceDescriptions-type.md)

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/sourceDescriptions-name-unique.ts)
65 changes: 65 additions & 0 deletions docs/rules/arazzo/sourceDescriptions-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# sourceDescription-type
lornajane marked this conversation as resolved.
Show resolved Hide resolved

The `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.
lornajane marked this conversation as resolved.
Show resolved Hide resolved

| Arazzo | Compatibility |
| ------ | ------------- |
| 1.0.0 | ✅ |

## API design principles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## API design principles
## Rationale


By the Arazzo standard the possible values for `sourceDescription.type` are "openapi" or "arazzo".
lornajane marked this conversation as resolved.
Show resolved Hide resolved

## Configuration

| Option | Type | Description |
| -------- | ------ | ------------------------------------------------------- |
| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. |

An example configuration:

```yaml
arazzoRules:
sourceDescription-type: error
lornajane marked this conversation as resolved.
Show resolved Hide resolved
```

## Examples

Given the following configuration:

```yaml
arazzoRules:
sourceDescription-type: error
lornajane marked this conversation as resolved.
Show resolved Hide resolved
```

Example of an **incorrect** sourceDescriptions array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
sourceDescriptions:
- name: museum-api
type: openapi
url: ../openapi.yaml
- name: tickets-from-museum-api
type: none
x-serverUrl: 'http://localhost/api'
```

Example of a **correct** sourceDescriptions array:
lornajane marked this conversation as resolved.
Show resolved Hide resolved

```yaml Object example
lornajane marked this conversation as resolved.
Show resolved Hide resolved
sourceDescriptions:
- name: museum-api
type: openapi
url: ../openapi.yaml
- name: tickets-from-museum-api
type: arazzo
url: museum-tickets.arazzo.yaml
```

## Related rules

- [sourceDescription-name-unique](./sourceDescriptions-name-unique.md)

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/sourceDescription-type.ts)
Loading
Loading