Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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).
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their address.
- `tag-description`: all tags require a description.
- `tags-alphabetical`: tags should be listed in the AsyncAPI file in alphabetical order.

Expand Down
12 changes: 4 additions & 8 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 All @@ -10,9 +6,9 @@ The criteria list must not contain duplicated assertions.
| ------ | ------------- |
| 1.0.0 | ✅ |

## API design principles
## Design principles

The criteria list must not contain duplicated assertions.
To avoid redundancy and confusion, the assertions in the criteria list must not be duplicated.

## Configuration

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

```yaml
arazzoRules:
rules:
criteria-unique: error
```

Expand All @@ -32,7 +28,7 @@ arazzoRules:
Given the following configuration:

```yaml
arazzoRules:
rules:
criteria-unique: error
```

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 | ✅ |

## Design principles

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.

This ruled checks parameter lists in the following locations:

- `workflows.[workflow].parameters`
- `workflows.[workflow[.steps.[step].parameters`
- `x-parameters`

## Configuration

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

An example configuration:

```yaml
rules:
parameters-unique: error
```

## Examples

Given the following configuration:

```yaml
rules:
parameters-unique: error
```

Example of an **incorrect** `parameters` list:

```yaml Incorrect example
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` list:

```yaml Correct example
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 | ✅ |

## Design principles

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
rules:
requestBody-replacements-unique: error
```

## Examples

Given the following configuration:

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

Example of an **incorrect** `replacements` list:

```yaml Incorrect example
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` list:

```yaml Correct example
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)
66 changes: 66 additions & 0 deletions docs/rules/arazzo/sourceDescriptions-name-unique.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# sourceDescriptions-name-unique

The `name` property of the Source Description object must be unique across all source descriptions.

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

## Design principles

To avoid confusion or unexpected outputs, each Source Description object should have a unique `name` property.
Especially in a longer list of sources, this could be difficult to identify and could have unwanted side effects.

## Configuration

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

An example configuration:

```yaml
rules:
sourceDescriptions-name-unique: error
```

## Examples

Given the following configuration:

```yaml
rules:
sourceDescriptions-name-unique: error
```

Example of an **incorrect** `sourceDescriptions` list:

```yaml Incorrect example
sourceDescriptions:
- name: museum-api
type: openapi
url: ../openapi.yaml
- name: museum-api
type: openapi
url: ../petstore.yaml
```

Example of a **correct** `sourceDescriptions` list:

```yaml Correct example
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)
94 changes: 94 additions & 0 deletions docs/rules/arazzo/sourceDescriptions-not-empty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# sourceDescriptions-not-empty

The Source Description must have at least one entry.

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

## Design principles

Source descriptions are an important part of an Arazzo description, and at least one entry must exist.
If the list is empty, this could indicate an omission or another problem; this rule alerts you if that happens.

## Configuration

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

An example configuration:

```yaml
rules:
sourceDescriptions-not-empty: error
```

## Examples

Given the following configuration:

```yaml
rules:
sourceDescriptions-not-empty: error
```

Example of an **incorrect** usage:

```yaml Incorrect example
arazzo: '1.0.0'
info:
title: Cool API
version: 1.0.0
description: A cool API
sourceDescriptions: []
workflows:
- workflowId: get-museum-hours
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
parameters:
- in: header
name: Authorization
value: Basic Og==
steps:
- stepId: get-museum-hours
description: >-
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
operationId: $sourceDescriptions.museum-api.getMuseumHours
successCriteria:
- condition: $statusCode == 200
```

Example of a **correct** usage:

```yaml Correct example
arazzo: '1.0.0'
info:
title: Cool API
version: 1.0.0
description: A cool API
sourceDescriptions:
- name: museum-api
type: openapi
url: openapi.yaml
- name: another-api
type: openapi
url: openapi.yaml
workflows:
- workflowId: get-museum-hours
description: This workflow demonstrates how to get the museum opening hours and buy tickets.
parameters:
- in: header
name: Authorization
value: Basic Og==
steps:
- stepId: get-museum-hours
description: >-
Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description.
operationId: $sourceDescriptions.museum-api.getMuseumHours
successCriteria:
- condition: $statusCode == 200
```

## Resources

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