Skip to content

Commit 6381911

Browse files
authored
feat: enable schema-related rules for AsyncAPI and Arazzo (#2183)
1 parent 62c72ad commit 6381911

27 files changed

+750
-140
lines changed

.changeset/tough-keys-compare.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@redocly/openapi-core": minor
3+
"@redocly/cli": minor
4+
---
5+
6+
Enabled `no-required-schema-properties-undefined`, `no-schema-type-mismatch`, and `no-enum-type-mismatch` rules for **AsyncAPI** and **Arazzo** specifications.
7+
Adjusted the rules' severities in the `recommended` and `minimal` rulesets. Refer to the following table:
8+
9+
| Rule \ Ruleset | recommended | minimal |
10+
| --------------------------------------- | ----------------- | --------------- |
11+
| no-required-schema-properties-undefined | `off` -> `warn` | `off` -> `warn` |
12+
| no-enum-type-mismatch | `error` | `warn` |
13+
| no-schema-type-mismatch | `warn` -> `error` | `off` -> `warn` |

docs/@v2/rules/built-in-rules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ The rules list is split into sections.
7878
### Requests, Responses, and Schemas
7979

8080
- [component-name-unique](./oas/component-name-unique.md): Check for schema-wide unqiue naming of parameters, schemas, request bodies and responses
81-
- [no-enum-type-mismatch](./oas/no-enum-type-mismatch.md): Enum options must match the data type declared in the schema
81+
- [no-enum-type-mismatch](./common/no-enum-type-mismatch.md): Enum options must match the data type declared in the schema
8282
- [no-example-value-and-externalValue](./oas/no-example-value-and-externalValue.md): Either the `value` or `externalValue` may be present, but not both
8383
- [no-invalid-media-type-examples](./oas/no-invalid-media-type-examples.md): Example request bodies must match the declared schema
8484
- [no-invalid-schema-examples](./oas/no-invalid-schema-examples.md): Schema examples must match declared types
85-
- [no-required-schema-properties-undefined](./oas/no-required-schema-properties-undefined.md): All properties marked as required must be defined
86-
- [no-schema-type-mismatch](./oas/no-schema-type-mismatch.md): Detects schemas with type mismatches between object and items fields, and array and properties fields.
85+
- [no-required-schema-properties-undefined](./common/no-required-schema-properties-undefined.md): All properties marked as required must be defined
86+
- [no-schema-type-mismatch](./common/no-schema-type-mismatch.md): Detects schemas with type mismatches between object and items fields, and array and properties fields.
8787
- [request-mime-type](./oas/request-mime-type.md): Configure allowed mime types for requests
8888
- [response-mime-type](./oas/response-mime-type.md): Configure allowed mime types for responses
8989
- [response-contains-header](./oas/response-contains-header.md): List headers that must be included with specific response types

docs/@v2/rules/oas/no-enum-type-mismatch.md renamed to docs/@v2/rules/common/no-enum-type-mismatch.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
slug: /docs/cli/v2/rules/oas/no-enum-type-mismatch
2+
slug:
3+
- /docs/cli/v2/rules/common/no-enum-type-mismatch
4+
- /docs/cli/v2/rules/oas/no-enum-type-mismatch
35
---
46

57
# no-enum-type-mismatch
@@ -31,6 +33,15 @@ end
3133
style Schema fill:#codaf9,stroke:#0044d4,stroke-width:5px
3234
```
3335

36+
| AsyncAPI | Compatibility |
37+
| -------- | ------------- |
38+
| 2.6 ||
39+
| 3.0 ||
40+
41+
| Arazzo | Compatibility |
42+
| ------ | ------------- |
43+
| 1.0 ||
44+
3445
## API design principles
3546

3647
If a property is defined for a certain type, then its corresponding `enum` values should comply with that type.
@@ -86,10 +97,12 @@ properties:
8697
8798
## Related rules
8899
100+
- [no-schema-type-mismatch](./no-schema-type-mismatch.md)
101+
- [no-required-schema-properties-undefined](./no-required-schema-properties-undefined.md)
89102
- [configurable rules](../configurable-rules.md)
90-
- [no-invalid-media-type-examples](./no-invalid-media-type-examples.md)
91-
- [no-invalid-parameter-examples](./no-invalid-parameter-examples.md)
92-
- [no-invalid-schema-examples](./no-invalid-schema-examples.md)
103+
- [no-invalid-media-type-examples](../oas/no-invalid-media-type-examples.md)
104+
- [no-invalid-parameter-examples](../oas/no-invalid-parameter-examples.md)
105+
- [no-invalid-schema-examples](../oas/no-invalid-schema-examples.md)
93106
94107
## Resources
95108

docs/@v2/rules/oas/no-required-schema-properties-undefined.md renamed to docs/@v2/rules/common/no-required-schema-properties-undefined.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
slug: /docs/cli/v2/rules/oas/no-required-schema-properties-undefined
2+
slug:
3+
- /docs/cli/v2/rules/common/no-required-schema-properties-undefined
4+
- /docs/cli/v2/rules/oas/no-required-schema-properties-undefined
35
---
46

57
# no-required-schema-properties-undefined
@@ -12,6 +14,11 @@ Ensures there are no required schema properties that are undefined.
1214
| 3.0 ||
1315
| 3.1 ||
1416

17+
| AsyncAPI | Compatibility |
18+
| -------- | ------------- |
19+
| 2.6 ||
20+
| 3.0 ||
21+
1522
```mermaid
1623
flowchart TD
1724
@@ -20,15 +27,19 @@ Root ==> Components ==> Schemas
2027
style Schemas fill:#codaf9,stroke:#0044d4,stroke-width:5px
2128
```
2229

30+
| Arazzo | Compatibility |
31+
| ------ | ------------- |
32+
| 1.0 ||
33+
2334
## API design principles
2435

2536
If a required schema property is declared but not defined, this rule informs you which of the required schema properties are missing.
2637

2738
## Configuration
2839

29-
| Option | Type | Description |
30-
| -------- | ------ | ---------------------------------------------------------------------------------------- |
31-
| severity | string | Possible values: `off`, `warn`, `error`. Default `off` (in `recommended` configuration). |
40+
| Option | Type | Description |
41+
| -------- | ------ | ----------------------------------------------------------------------------------------- |
42+
| severity | string | Possible values: `off`, `warn`, `error`. Default `warn` (in `recommended` configuration). |
3243

3344
An example configuration:
3445

@@ -100,7 +111,9 @@ schemas:
100111

101112
## Related rules
102113

103-
- [no-invalid-schema-examples](./no-invalid-schema-examples.md)
114+
- [no-schema-type-mismatch](./no-schema-type-mismatch.md)
115+
- [no-enum-type-mismatch](./no-enum-type-mismatch.md)
116+
- [no-invalid-schema-examples](../oas/no-invalid-schema-examples.md)
104117

105118
## Resources
106119

docs/@v2/rules/oas/no-schema-type-mismatch.md renamed to docs/@v2/rules/common/no-schema-type-mismatch.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
slug: /docs/cli/v2/rules/oas/no-schema-type-mismatch
2+
slug:
3+
- /docs/cli/v2/rules/common/no-schema-type-mismatch
4+
- /docs/cli/v2/rules/oas/no-schema-type-mismatch
35
---
46

57
# no-schema-type-mismatch
@@ -15,6 +17,15 @@ Ensures that a schema's structural properties match its declared `type`. In part
1517
| 3.0 ||
1618
| 3.1 ||
1719

20+
| AsyncAPI | Compatibility |
21+
| -------- | ------------- |
22+
| 2.6 ||
23+
| 3.0 ||
24+
25+
| Arazzo | Compatibility |
26+
| ------ | ------------- |
27+
| 1.0 ||
28+
1829
```mermaid
1930
flowchart TD
2031
Schema -->|if type is object| CheckItems["'items' field exists?"]
@@ -102,10 +113,12 @@ properties:
102113

103114
## Related rules
104115

116+
- [no-enum-type-mismatch](./no-enum-type-mismatch.md)
117+
- [no-required-schema-properties-undefined](./no-required-schema-properties-undefined.md)
105118
- [configurable rules](../configurable-rules.md)
106-
- [no-invalid-media-type-examples](./no-invalid-media-type-examples.md)
107-
- [no-invalid-parameter-examples](./no-invalid-parameter-examples.md)
108-
- [no-invalid-schema-examples](./no-invalid-schema-examples.md)
119+
- [no-invalid-media-type-examples](../oas/no-invalid-media-type-examples.md)
120+
- [no-invalid-parameter-examples](../oas/no-invalid-parameter-examples.md)
121+
- [no-invalid-schema-examples](../oas/no-invalid-schema-examples.md)
109122

110123
## Resources
111124

docs/@v2/rules/minimal.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ Warnings:
2020
- [configurable rules](./configurable-rules.md)
2121
- [no-ambiguous-paths](./oas/no-ambiguous-paths.md)
2222
- [no-empty-servers](./oas/no-empty-servers.md)
23-
- [no-enum-type-mismatch](./oas/no-enum-type-mismatch.md)
23+
- [no-enum-type-mismatch](./common/no-enum-type-mismatch.md)
24+
- [no-required-schema-properties-undefined](./common/no-required-schema-properties-undefined.md)
25+
- [no-schema-type-mismatch](./common/no-schema-type-mismatch.md)
2426
- [no-example-value-and-externalValue](./oas/no-example-value-and-externalValue.md)
2527
- [no-identical-paths](./oas/no-identical-paths.md)
2628
- [no-invalid-media-type-examples](./oas/no-invalid-media-type-examples.md)

docs/@v2/rules/oas/no-invalid-media-type-examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ post:
150150
151151
- [no-invalid-parameter-examples](./no-invalid-parameter-examples.md)
152152
- [no-invalid-schema-examples](./no-invalid-schema-examples.md)
153-
- [no-enum-type-mismatch](./no-enum-type-mismatch.md)
153+
- [no-enum-type-mismatch](../common/no-enum-type-mismatch.md)
154154
155155
## Resources
156156

docs/@v2/rules/recommended.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ These are the rules in the `recommended` set, grouped by their severity.
99
Errors:
1010

1111
- [no-empty-servers](./oas/no-empty-servers.md)
12-
- [no-enum-type-mismatch](./oas/no-enum-type-mismatch.md)
12+
- [no-enum-type-mismatch](./common/no-enum-type-mismatch.md)
13+
- [no-schema-type-mismatch](./common/no-schema-type-mismatch.md)
1314
- [no-example-value-and-externalValue](./oas/no-example-value-and-externalValue.md)
1415
- [no-identical-paths](./oas/no-identical-paths.md)
1516
- [no-path-trailing-slash](./oas/no-path-trailing-slash.md)
@@ -42,6 +43,7 @@ Warnings:
4243
- [info-license-strict](./oas/info-license-strict.md)
4344
- [no-ambiguous-paths](./oas/no-ambiguous-paths.md)
4445
- [no-invalid-media-type-examples](./oas/no-invalid-media-type-examples.md)
46+
- [no-required-schema-properties-undefined](./common/no-required-schema-properties-undefined.md)
4547
- [no-server-example.com](./oas/no-server-example-com.md)
4648
- [no-unused-components](./oas/no-unused-components.md)
4749
- [operation-2xx-response](./oas/operation-2xx-response.md)

0 commit comments

Comments
 (0)