-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: clean up the discriminator mapping in the remove-x-internal deco…
…rator (#1694) * fix: remove the discriminator mapping in the remove-x-internal decorator * add a test for discriminators with $refs to files * collect original discriminator mapping before resolving to compare $refs to the actual files * add check for mapping to be an object
- Loading branch information
Showing
10 changed files
with
227 additions
and
15 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 the `remove-x-internal` decorator, which was not removing the reference in the corresponding discriminator mapping while removing the original `$ref`. |
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,25 @@ | ||
openapi: 3.1.0 | ||
info: {} | ||
paths: | ||
/test: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/christmas-tree' | ||
components: | ||
schemas: | ||
christmas-tree: | ||
type: array | ||
items: | ||
discriminator: | ||
propertyName: type | ||
mapping: | ||
candy-cane: schemas/candy-cane.yaml | ||
popcorn: schemas/popcorn.yaml | ||
cranberry: schemas/cranberry.yaml | ||
anyOf: | ||
- $ref: schemas/candy-cane.yaml | ||
- $ref: schemas/popcorn.yaml | ||
- $ref: schemas/cranberry.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,5 @@ | ||
apis: | ||
main: | ||
root: ./main.yaml | ||
decorators: | ||
remove-x-internal: on |
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,7 @@ | ||
x-internal: true | ||
title: candy-cane | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: [candy-cane] |
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,5 @@ | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: [cranberry] |
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,5 @@ | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: [popcorn] |
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,45 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`E2E bundle remove-x-internal 1`] = ` | ||
openapi: 3.1.0 | ||
info: {} | ||
paths: | ||
/test: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/christmas-tree' | ||
components: | ||
schemas: | ||
christmas-tree: | ||
type: array | ||
items: | ||
discriminator: | ||
propertyName: type | ||
mapping: | ||
popcorn: '#/components/schemas/popcorn' | ||
cranberry: '#/components/schemas/cranberry' | ||
anyOf: | ||
- $ref: '#/components/schemas/popcorn' | ||
- $ref: '#/components/schemas/cranberry' | ||
popcorn: | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: | ||
- popcorn | ||
cranberry: | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: | ||
- cranberry | ||
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
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
ca08c1b
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
811 tests passing in 121 suites.
Report generated by 🧪jest coverage report action from ca08c1b