-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: report on child keys when using pattern or notPattern assertions (…
- Loading branch information
Showing
6 changed files
with
116 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@redocly/openapi-core': patch | ||
'@redocly/cli': patch | ||
--- | ||
|
||
Changed the report location for `pattern` and `notPattern` assertions to be more precise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
__tests__/lint/assertions-pattern-report-location/openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
openapi: 3.1.0 | ||
paths: | ||
/one: | ||
description: A correct path item name | ||
get: | ||
parameters: | ||
- name: Correct | ||
in: header | ||
- name: Wrong | ||
in: header | ||
/two/test: | ||
description: A wrong path item name | ||
/two/ref: | ||
$ref: '#/components/paths/' | ||
components: | ||
pathItems: | ||
ReferencedPathItem: | ||
description: Referenced from a wrong path item name |
19 changes: 19 additions & 0 deletions
19
__tests__/lint/assertions-pattern-report-location/redocly.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apis: | ||
main: | ||
root: ./openapi.yaml | ||
|
||
rules: | ||
rule/restful-paths: | ||
subject: | ||
type: Paths | ||
assertions: | ||
notPattern: '/[^{/}]+/[^{/}]+/' | ||
message: Two consecutive path segments don't have a variable | ||
|
||
rule/parameters-name: | ||
subject: | ||
type: Parameter | ||
property: name | ||
assertions: | ||
pattern: /Correct/ | ||
message: Parameters name should contain the `Correct` word |
54 changes: 54 additions & 0 deletions
54
__tests__/lint/assertions-pattern-report-location/snapshot.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E lint assertions-pattern-report-location 1`] = ` | ||
validating /openapi.yaml... | ||
[1] openapi.yaml:11:3 at #/paths/~1two~1test | ||
Two consecutive path segments don't have a variable | ||
9 | - name: Wrong | ||
10 | in: header | ||
11 | /two/test: | ||
| ^^^^^^^^^ | ||
12 | description: A wrong path item name | ||
13 | /two/ref: | ||
Error was generated by the rule/restful-paths rule. | ||
[2] openapi.yaml:13:3 at #/paths/~1two~1ref | ||
Two consecutive path segments don't have a variable | ||
11 | /two/test: | ||
12 | description: A wrong path item name | ||
13 | /two/ref: | ||
| ^^^^^^^^ | ||
14 | $ref: '#/components/paths/' | ||
15 | components: | ||
Error was generated by the rule/restful-paths rule. | ||
[3] openapi.yaml:9:17 at #/paths/~1one/get/parameters/1/name | ||
Parameters name should contain the \`Correct\` word | ||
7 | - name: Correct | ||
8 | in: header | ||
9 | - name: Wrong | ||
| ^^^^^ | ||
10 | in: header | ||
11 | /two/test: | ||
Error was generated by the rule/parameters-name rule. | ||
/openapi.yaml: validated in <test>ms | ||
❌ Validation failed with 3 errors. | ||
run \`redocly lint --generate-ignore-file\` to add all problems to the ignore file. | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d703d22
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report
Test suite run success
641 tests passing in 93 suites.
Report generated by 🧪jest coverage report action from d703d22