-
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: false positive errors when validating examples with refs (#1377)
- Loading branch information
Showing
10 changed files
with
137 additions
and
10 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 | ||
--- | ||
|
||
Fixed a problem where the linter incorrectly returned an error for valid examples that contain references. |
11 changes: 11 additions & 0 deletions
11
..._/lint/no-invalid-media-type-examples-multiple-valid-refs-different-files/components.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,11 @@ | ||
components: | ||
schemas: | ||
A: | ||
type: object | ||
properties: | ||
a: | ||
type: string | ||
b: | ||
$ref: '#/components/schemas/B' | ||
B: | ||
type: string |
21 changes: 21 additions & 0 deletions
21
...ts__/lint/no-invalid-media-type-examples-multiple-valid-refs-different-files/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,21 @@ | ||
openapi: 3.1.0 | ||
components: | ||
schemas: | ||
C: | ||
$ref: './components.yaml#/components/schemas/A' | ||
D: | ||
$ref: './components.yaml#/components/schemas/A' | ||
paths: | ||
/pet: | ||
get: | ||
responses: | ||
200: | ||
content: | ||
application/json: | ||
example: { 'a': 'test', 'b': 'test' } | ||
schema: | ||
$ref: '#/components/schemas/C' | ||
application/x+json: | ||
example: { 'a': 'test', 'b': 'test' } | ||
schema: | ||
$ref: '#/components/schemas/D' |
6 changes: 6 additions & 0 deletions
6
...ts__/lint/no-invalid-media-type-examples-multiple-valid-refs-different-files/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,6 @@ | ||
apis: | ||
main: | ||
root: ./openapi.yaml | ||
|
||
rules: | ||
no-invalid-media-type-examples: error |
11 changes: 11 additions & 0 deletions
11
...sts__/lint/no-invalid-media-type-examples-multiple-valid-refs-different-files/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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E lint no-invalid-media-type-examples-multiple-valid-refs-different-files 1`] = ` | ||
validating /openapi.yaml... | ||
/openapi.yaml: validated in <test>ms | ||
Woohoo! Your API description is valid. 🎉 | ||
`; |
53 changes: 53 additions & 0 deletions
53
__tests__/lint/no-invalid-media-type-examples-multiple-valid-refs/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,53 @@ | ||
openapi: 3.1.0 | ||
paths: | ||
/foo: | ||
get: | ||
responses: | ||
'200': | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/foo' | ||
examples: | ||
ValidFoo: | ||
value: | ||
id: 1 | ||
/bar: | ||
get: | ||
responses: | ||
'200': | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/bar' | ||
examples: | ||
ValidBar: | ||
value: | ||
id: 1 | ||
application/baz+json: | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
$ref: '#/components/schemas/baz' | ||
examples: | ||
ValidBaz: | ||
value: # | ||
id: 3 | ||
|
||
components: | ||
schemas: | ||
commonId: | ||
type: integer | ||
foo: | ||
$ref: '#/components/schemas/commonId' | ||
bar: | ||
$ref: '#/components/schemas/commonId' | ||
baz: | ||
$ref: '#/components/schemas/commonId' |
6 changes: 6 additions & 0 deletions
6
__tests__/lint/no-invalid-media-type-examples-multiple-valid-refs/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,6 @@ | ||
apis: | ||
main: | ||
root: ./openapi.yaml | ||
|
||
rules: | ||
no-invalid-media-type-examples: error |
11 changes: 11 additions & 0 deletions
11
__tests__/lint/no-invalid-media-type-examples-multiple-valid-refs/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,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E lint no-invalid-media-type-examples-multiple-valid-refs 1`] = ` | ||
validating /openapi.yaml... | ||
/openapi.yaml: validated in <test>ms | ||
Woohoo! Your API description is valid. 🎉 | ||
`; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
5573a61
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
671 tests passing in 94 suites.
Report generated by 🧪jest coverage report action from 5573a61