Skip to content

Commit

Permalink
fix: introduce new built-in rule for missing required schema properti…
Browse files Browse the repository at this point in the history
…es (#1412)

* fix: introduce new custom rule for missing required schema properties, along along with tests and changeset
* fix: add code implementation to cover anyOf keyword schema nestings, add more tests
  • Loading branch information
malis42 authored Feb 13, 2024
1 parent fd79f7d commit 4d01896
Show file tree
Hide file tree
Showing 11 changed files with 619 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-onions-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/openapi-core": minor
---

Added new `no-required-schema-properties-undefined` rule to check if each required schema property is defined.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
"no-invalid-parameter-examples": "off",
"no-invalid-schema-examples": "off",
"no-path-trailing-slash": "error",
"no-required-schema-properties-undefined": "off",
"no-unresolved-refs": "error",
"operation-2xx-response": "warn",
"operation-4xx-response": "error",
Expand Down Expand Up @@ -198,6 +199,7 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
"no-invalid-parameter-examples": "off",
"no-invalid-schema-examples": "off",
"no-path-trailing-slash": "error",
"no-required-schema-properties-undefined": "off",
"no-unresolved-refs": "error",
"operation-2xx-response": "error",
"operation-4xx-response": "off",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const all: PluginStyleguideConfig<'built-in'> = {
'path-params-defined': 'error',
'required-string-property-missing-min-length': 'error',
'response-contains-header': 'error',
'no-required-schema-properties-undefined': 'error',
},
oas2Rules: {
'boolean-parameter-prefixes': 'error',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
'response-contains-header': 'off',
'path-segment-plural': 'off',
'scalar-property-missing-example': 'off',
'no-required-schema-properties-undefined': 'off',
},
oas2Rules: {
'boolean-parameter-prefixes': 'off',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/recommended-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
'required-string-property-missing-min-length': 'off',
'response-contains-header': 'off',
'scalar-property-missing-example': 'off',
'no-required-schema-properties-undefined': 'off',
},
oas2Rules: {
'boolean-parameter-prefixes': 'off',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
'required-string-property-missing-min-length': 'off',
'response-contains-header': 'off',
'scalar-property-missing-example': 'off',
'no-required-schema-properties-undefined': 'off',
},
oas2Rules: {
'boolean-parameter-prefixes': 'off',
Expand Down
Loading

1 comment on commit 4d01896

@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 76.19% 4322/5673
🟡 Branches 65.94% 2254/3418
🟡 Functions 68.9% 698/1013
🟡 Lines 76.39% 4063/5319

Test suite run success

710 tests passing in 101 suites.

Report generated by 🧪jest coverage report action from 4d01896

Please sign in to comment.