Skip to content

Commit

Permalink
chore: document requestBody-replacements-unique rule
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky committed Aug 30, 2024
1 parent d209f56 commit 2607b4f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
4 changes: 1 addition & 3 deletions docs/rules/arazzo/parameters-unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ style Contact fill:#codaf9,stroke:#0044d4,stroke-width:5px

## API design principles

A list of `parameters` that are applicable for step or all steps described under workflow should not be duplicated to avoid shallow parameter override.
A list of `parameters` that are applicable to step or all steps described under workflow should not be duplicated to avoid shadow parameter override.

## Configuration

Expand Down Expand Up @@ -88,8 +88,6 @@ workflows:
value: Main Og==
```
## Related rules
## Resources
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/parameters-unique.ts)
87 changes: 87 additions & 0 deletions docs/rules/arazzo/requestBody-replacements-unique.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
slug: /docs/cli/rules/arazzo/requestBody-replacements-unique
---

# requestBody-replacements-unique

Requires the `replacements` of the `requestBody` object to be unique.

| ARAZZO | Compatibility |
| ------ | ------------- |
| 1.0.0 ||

```mermaid
flowchart TD
Root ==> workflows --> workflow --> steps --> step --> requestBody --> replacements
style Contact fill:#codaf9,stroke:#0044d4,stroke-width:5px
```

## API design principles

A 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** license:
```yaml Object 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'
```
Example of a **correct** license:
```yaml Object 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'
```
## Resources
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/requestBody-replacements-unique.ts)
1 change: 1 addition & 0 deletions docs/rules/recommended.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Warnings:
- [tag-description](./tag-description.md)
- [version-enum](./spot/version-enum.md)
- [parameters-not-in-body](./spot/parameters-not-in-body.md)
- [requestBody-replacements-unique](./arazzo/requestBody-replacements-unique.md)

## Recommended strict ruleset

Expand Down

0 comments on commit 2607b4f

Please sign in to comment.