-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bundle externalValue with relative reference in examples object (#…
…1747) --------- Co-authored-by: Jacek Łękawa <[email protected]>
- Loading branch information
1 parent
1f0ca52
commit 67ea331
Showing
10 changed files
with
182 additions
and
1 deletion.
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 an issue where the bundle command did not resolve links in `externalValue`. |
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,4 @@ | ||
{ | ||
"foo": "bar", | ||
"key": "value" | ||
} |
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,8 @@ | ||
apis: | ||
first: | ||
root: ./test-success.yaml | ||
second: | ||
root: ./test-wrong-examples.yaml | ||
|
||
extends: | ||
- recommended |
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,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E bundle bundle-external-value 1`] = ` | ||
openapi: 3.1.0 | ||
info: | ||
version: 1.0.0 | ||
title: Example.com | ||
termsOfService: https://example.com/terms/ | ||
contact: | ||
email: [email protected] | ||
url: http://example.com/contact | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
description: OpenAPI description with external example | ||
security: [] | ||
paths: | ||
/: | ||
post: | ||
summary: Test request externalValue with relative reference in examples | ||
requestBody: | ||
content: | ||
application/xml: | ||
schema: | ||
type: object | ||
examples: | ||
test-resolved: | ||
summary: Example should resolved to value | ||
value: | ||
foo: bar | ||
key: value | ||
test-no-resolved: | ||
summary: Example shouldn't be resolved to value | ||
value: | ||
type: object | ||
externalValue: ./external-value.json | ||
components: {} | ||
bundling ./test-success.yaml... | ||
📦 Created a bundle for ./test-success.yaml at stdout <test>ms. | ||
bundling ./test-wrong-examples.yaml... | ||
[1] test-wrong-examples.yaml:27:17 at #/paths/~1/post/requestBody/content/application~1xml/examples/test-wrong-ref | ||
Can't resolve $ref: ENOENT: no such file or directory './__tests__/bundle/bundle-external-value/external-value-bad-path.json' | ||
25 | examples: | ||
26 | test-wrong-ref: | ||
27 | summary: Example shouldn't resolved to value | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
28 | externalValue: './external-value-bad-path.json' | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
29 | | ||
Error was generated by the bundler rule. | ||
❌ Errors encountered while bundling ./test-wrong-examples.yaml: bundle not created (use --force to ignore errors). | ||
`; |
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,33 @@ | ||
openapi: 3.1.0 | ||
security: [] | ||
info: | ||
version: 1.0.0 | ||
title: Example.com | ||
termsOfService: https://example.com/terms/ | ||
contact: | ||
email: [email protected] | ||
url: http://example.com/contact | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
description: OpenAPI description with external example | ||
components: {} | ||
|
||
paths: | ||
/: | ||
post: | ||
summary: Test request externalValue with relative reference in examples | ||
requestBody: | ||
content: | ||
application/xml: | ||
schema: | ||
type: object | ||
examples: | ||
test-resolved: | ||
summary: Example should resolved to value | ||
externalValue: './external-value.json' | ||
test-no-resolved: | ||
summary: Example shouldn't be resolved to value | ||
value: | ||
type: object | ||
externalValue: './external-value.json' |
28 changes: 28 additions & 0 deletions
28
__tests__/bundle/bundle-external-value/test-wrong-examples.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,28 @@ | ||
openapi: 3.1.0 | ||
security: [] | ||
info: | ||
version: 1.0.0 | ||
title: Example.com | ||
termsOfService: https://example.com/terms/ | ||
contact: | ||
email: [email protected] | ||
url: http://example.com/contact | ||
license: | ||
name: Apache 2.0 | ||
url: http://www.apache.org/licenses/LICENSE-2.0.html | ||
description: OpenAPI description with external example | ||
components: {} | ||
|
||
paths: | ||
/: | ||
post: | ||
summary: Test request externalValue with relative reference in examples | ||
requestBody: | ||
content: | ||
application/xml: | ||
schema: | ||
type: object | ||
examples: | ||
test-wrong-ref: | ||
summary: Example shouldn't resolved to value | ||
externalValue: './external-value-bad-path.json' |
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
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
2 changes: 2 additions & 0 deletions
2
packages/core/src/rules/oas3/__tests__/fixtures/external-value.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,2 @@ | ||
a: foo | ||
b: 100 |
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
67ea331
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
809 tests passing in 121 suites.
Report generated by 🧪jest coverage report action from 67ea331