-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong discriminator mapping when bundling with derefernce (#1666)
* fix: wrong discriminator mapping when bundling with derefernce * add changeset
- Loading branch information
Showing
8 changed files
with
144 additions
and
8 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 bundling with the `--dereferenced` option. Previously, references to external files were not substituted with references to components, causing them to become invalid. |
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 @@ | ||
type: object | ||
properties: | ||
discriminatedProp: | ||
type: string | ||
bar: | ||
type: boolean |
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 @@ | ||
type: object | ||
properties: | ||
discriminatedProp: | ||
type: string | ||
foo: | ||
type: string |
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 @@ | ||
openapi: 3.1.0 | ||
info: {} | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
default: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
discriminator: | ||
propertyName: discriminatedProp | ||
mapping: | ||
Foo: ./foo.yaml | ||
Bar: ./bar.yaml | ||
oneOf: | ||
- $ref: ./foo.yaml | ||
- $ref: ./bar.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,3 @@ | ||
apis: | ||
main: | ||
root: ./main.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,87 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E bundle discriminator-mapping 1`] = ` | ||
openapi: 3.1.0 | ||
info: {} | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
default: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
discriminator: | ||
propertyName: discriminatedProp | ||
mapping: | ||
Foo: '#/components/schemas/foo' | ||
Bar: '#/components/schemas/bar' | ||
oneOf: | ||
- $ref: '#/components/schemas/foo' | ||
- $ref: '#/components/schemas/bar' | ||
components: | ||
schemas: | ||
foo: | ||
type: object | ||
properties: | ||
discriminatedProp: | ||
type: string | ||
foo: | ||
type: string | ||
bar: | ||
type: object | ||
properties: | ||
discriminatedProp: | ||
type: string | ||
bar: | ||
type: boolean | ||
bundling ./main.yaml... | ||
📦 Created a bundle for ./main.yaml at stdout <test>ms. | ||
`; | ||
|
||
exports[`E2E bundle with option: dereferenced discriminator mapping should be replaced with correct references to components 1`] = ` | ||
openapi: 3.1.0 | ||
info: {} | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
default: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
discriminator: | ||
propertyName: discriminatedProp | ||
mapping: | ||
Foo: '#/components/schemas/foo' | ||
Bar: '#/components/schemas/bar' | ||
oneOf: | ||
- type: object | ||
properties: &ref_0 | ||
discriminatedProp: | ||
type: string | ||
foo: | ||
type: string | ||
- type: object | ||
properties: &ref_1 | ||
discriminatedProp: | ||
type: string | ||
bar: | ||
type: boolean | ||
components: | ||
schemas: | ||
foo: | ||
type: object | ||
properties: *ref_0 | ||
bar: | ||
type: object | ||
properties: *ref_1 | ||
bundling main.yaml... | ||
📦 Created a bundle for main.yaml at stdout <test>ms. | ||
`; |
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
5a493e7
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 5a493e7