Skip to content

Commit

Permalink
feat: rules refactoring / add separate arazzo rule-set (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky authored Dec 9, 2024
1 parent 7ba0d13 commit f959e4c
Show file tree
Hide file tree
Showing 164 changed files with 1,850 additions and 939 deletions.
6 changes: 6 additions & 0 deletions .changeset/purple-lobsters-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@redocly/openapi-core": patch
"@redocly/cli": patch
---

Updated `sourceDescriptions` to enforce a valid type field, ensuring compliance with the Arazzo specification.
7 changes: 7 additions & 0 deletions .changeset/strong-ties-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@redocly/openapi-core": minor
"@redocly/cli": minor
---

Introduced the `struct` rule and deprecated the `spec` rule.
Added the `spec` ruleset, which enforces compliance with the specifications.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`E2E check-config config type extension in assertions 1`] = `
The 'spec' field is deprecated. Use struct instead.
✅ Your config is valid.
`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins:
- plugins/type-extention.js

rules:
spec: warn
struct: warn
rule/metadata-lifecycle:
subject:
type: WrongXMetaData
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The field \`title\` must be present on this level.
5 | description: Example description
6 | version: '1.0'
Error was generated by the spec rule.
Error was generated by the struct rule.
[2] ../__fixtures__/invalid-openapi.yaml:10:5 at #/paths/~1pet~1findByStatus/get/summary
Expand All @@ -60,7 +60,7 @@ Expected type \`Responses\` (object) but got \`null\`
| ^^^^^^^^^^
12 |
Error was generated by the spec rule.
Error was generated by the struct rule.
[4] ../__fixtures__/invalid-openapi.yaml:4:1 at #/info
Expand Down
4 changes: 2 additions & 2 deletions __tests__/lint/arazzo-not-valid-test-description/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The field \`info\` must be present on this level.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
Error was generated by the spec rule.
Error was generated by the struct rule.
[2] museum.yaml:9:5 at #/workflows/0
Expand All @@ -36,7 +36,7 @@ The field \`steps\` must be present on this level.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18 |
Error was generated by the spec rule.
Error was generated by the struct rule.
museum.yaml: validated in <test>ms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const XMetaData = {
module.exports = {
id: 'type-extension',
typeExtension: {
arazzo(types) {
arazzo1(types) {
newTypes = {
...types,
XMetaData: XMetaData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins:
- plugins/type-extention.js

arazzoRules:
spec: error
arazzo1Rules:
struct: error
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Property \`wrong-key\` is not expected here.
9 | metadata:
10 | lifecycle: production
Error was generated by the spec rule.
Error was generated by the struct rule.
museum.yaml: validated in <test>ms
Expand Down
2 changes: 1 addition & 1 deletion __tests__/lint/async2/redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ apis:
root: ./websocket-gemini.yml

rules:
spec: error
struct: error
2 changes: 1 addition & 1 deletion __tests__/lint/async3/redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ apis:
root: ./websocket-gemini.yml

rules:
spec: error
struct: error
2 changes: 1 addition & 1 deletion __tests__/lint/deprecated-apiDefinitions/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`E2E lint deprecated-apiDefinitions 1`] = `
The 'apiDefinitions' field is deprecated. Use apis instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties
The 'apiDefinitions' field is deprecated. Use apis instead.
The 'lint' field is deprecated. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties
[1] redocly.yaml:1:1 at #/apiDefinitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Expected type \`array\` but got \`string\`.
| ^^^^^^
46 |
Error was generated by the spec rule.
Error was generated by the struct rule.
[4] openapi.yaml:2:1 at #/info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The \`type\` field must be defined when the \`nullable\` field is used.
17 | paths:
18 | /test:
Error was generated by the spec rule.
Error was generated by the struct rule.
[2] openapi.yaml:28:17 at #/paths/~1test/get/responses/202/content/application~1json/schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Expected type \`string\` but got \`null\`.
8 | description: Dev Environment.
9 | security: []
Error was generated by the spec rule.
Error was generated by the struct rule.
[2] openapi.yaml:2:1 at #/info
Expand Down
2 changes: 1 addition & 1 deletion __tests__/lint/null-schema-values/redocly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ apis:
root: ./openapi.yaml

rules:
spec: error
struct: error
no-unused-components: error
4 changes: 2 additions & 2 deletions __tests__/lint/null-schema-values/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Expected type \`Info\` (object) but got \`null\`
3 | paths:
4 | /test:
Error was generated by the spec rule.
Error was generated by the struct rule.
[2] openapi.yaml:15:5 at #/components/schemas/EmptySchema
Expand All @@ -28,7 +28,7 @@ Expected type \`Schema\` (object) but got \`null\`
referenced from openapi.yaml:12:17 at #/paths/~1test/get/responses/200/content/application~1json/schema
Error was generated by the spec rule.
Error was generated by the struct rule.
/openapi.yaml: validated in <test>ms
Expand Down
2 changes: 1 addition & 1 deletion __tests__/lint/oas3.1-error/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Must contain at least one of the following fields: paths, components, webhooks.
| ^^^^^^^^^^^^
24 |
Error was generated by the spec rule.
Error was generated by the struct rule.
/openapi.yaml: validated in <test>ms
Expand Down
Loading

1 comment on commit f959e4c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.66% 5055/6426
🟡 Branches 67.29% 2055/3054
🟡 Functions 73.23% 837/1143
🟡 Lines 78.95% 4767/6038

Test suite run success

836 tests passing in 122 suites.

Report generated by 🧪jest coverage report action from f959e4c

Please sign in to comment.