Skip to content

Commit 5ca0e2c

Browse files
committed
docs: reuse code snippet to show configurable rule per api
1 parent 69bd21d commit 5ca0e2c

File tree

5 files changed

+63
-62
lines changed

5 files changed

+63
-62
lines changed

docs/@v1/guides/configure-rules.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,11 @@ Not all APIs are made equal. Perhaps your newsletter signup microservice is held
114114

115115
You can configure linting differently for multiple APIs in a Redocly configuration file. Here's an example with three APIs defined, and different rules applied for each:
116116

117-
```yaml
118-
extends:
119-
- recommended
120-
121-
apis:
122-
partnerApi@1:
123-
root: partners.yaml
124-
rules:
125-
no-server-trailing-slash: off
126-
operation-operationId: off
127-
128-
newsletter@3:
129-
root: /absolute/path/to/folder/openapi.yaml
130-
extends:
131-
- minimal
132-
rules:
133-
no-server-trailing-slash: off
134-
135-
UserApi@1:
136-
root: users.yaml
137-
rules:
138-
no-server-trailing-slash: off
139-
operation-operationId: warn
140-
assert/version-semver:
141-
subject:
142-
type: Info
143-
property: version
144-
assertions:
145-
pattern: /1.[0-9]\.[0-9]/
146-
message: API version must be in SemVer format, no major version release
147-
```
117+
{% code-snippet
118+
file="../../_code-snippets/per-api-rules-example.yaml"
119+
language="yaml"
120+
title="redocly.yaml"
121+
/%}
148122

149123
There's a few things going on in the example, but let's look at each feature in turn:
150124

docs/@v1/rules/configure-rules.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ apis:
5353

5454
Each API picks up the settings that relate to it and gets linted accordingly.
5555

56+
## Per-API configuration with configurable rules
57+
58+
You can use configurable rules for individual APIs.
59+
In the following example, `UserApi@1` has a configurable rule defined.
60+
This rule applies only to `UserApi@1`.
61+
62+
{% code-snippet
63+
file="../../_code-snippets/per-api-rules-example.yaml"
64+
language="yaml"
65+
title="redocly.yaml"
66+
/%}
67+
5668
## Resources
5769

5870
- Learn more about [rules and rulesets](../rules.md).

docs/@v2/guides/configure-rules.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -123,37 +123,11 @@ Whatever the reason, per-API configuration can be useful in these situations.
123123
You can configure linting differently for multiple APIs in a Redocly configuration file.
124124
Here's an example with three APIs defined, and different rules applied for each:
125125

126-
```yaml
127-
extends:
128-
- recommended
129-
130-
apis:
131-
partnerApi@1:
132-
root: partners.yaml
133-
rules:
134-
no-server-trailing-slash: off
135-
operation-operationId: off
136-
137-
newsletter@3:
138-
root: /absolute/path/to/folder/openapi.yaml
139-
extends:
140-
- minimal
141-
rules:
142-
no-server-trailing-slash: off
143-
144-
UserApi@1:
145-
root: users.yaml
146-
rules:
147-
no-server-trailing-slash: off
148-
operation-operationId: warn
149-
rule/version-semver:
150-
subject:
151-
type: Info
152-
property: version
153-
assertions:
154-
pattern: /1.[0-9]\.[0-9]/
155-
message: API version must be in SemVer format, no major version release
156-
```
126+
{% code-snippet
127+
file="../../_code-snippets/per-api-rules-example.yaml"
128+
language="yaml"
129+
title="redocly.yaml"
130+
/%}
157131

158132
There's a few things going on in the example, but let's look at each feature in turn:
159133

docs/@v2/rules/configure-rules.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ apis:
5353

5454
Each API picks up the settings that relate to it and gets linted accordingly.
5555

56+
## Per-API configuration with configurable rules
57+
58+
You can use configurable rules for individual APIs.
59+
In the following example, `UserApi@1` has a configurable rule defined.
60+
This rule applies only to `UserApi@1`.
61+
62+
{% code-snippet
63+
file="../../_code-snippets/per-api-rules-example.yaml"
64+
language="yaml"
65+
title="redocly.yaml"
66+
/%}
67+
5668
## Resources
5769

5870
- Learn more about [rules and rulesets](../rules.md).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extends:
2+
- recommended
3+
4+
apis:
5+
partnerApi@1:
6+
root: partners.yaml
7+
rules:
8+
no-server-trailing-slash: off
9+
operation-operationId: off
10+
11+
newsletter@3:
12+
root: /absolute/path/to/folder/openapi.yaml
13+
extends:
14+
- minimal
15+
rules:
16+
no-server-trailing-slash: off
17+
18+
UserApi@1:
19+
root: users.yaml
20+
rules:
21+
no-server-trailing-slash: off
22+
operation-operationId: warn
23+
assert/version-semver:
24+
subject:
25+
type: Info
26+
property: version
27+
assertions:
28+
pattern: /1.[0-9]\.[0-9]/
29+
message: API version must be in SemVer format, no major version release

0 commit comments

Comments
 (0)