-
-
Notifications
You must be signed in to change notification settings - Fork 528
Bugfix for discriminators using allOf #1578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1f6dea4
b645047
0d8c81c
ffbe547
ce292e7
df9e8b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,20 +258,12 @@ describe("composition", () => { | |
"discriminator > oneOf", | ||
{ | ||
given: { | ||
type: "object", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @drwpow I was unsure why there is already an object here for the test of a oneOf discriminator, so I removed it. Maybe the implicit allOf merging here should be in a separate unit test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this actually should be its own test, you’re right, but it’s important we keep this “wrong” testcase. We still get so many bug reports and code examples of people combining |
||
required: ["name"], | ||
properties: { | ||
name: { type: "string" }, | ||
}, | ||
oneOf: [ | ||
{ $ref: "#/components/schemas/Cat" }, | ||
{ $ref: "#/components/schemas/Dog" }, | ||
], | ||
}, | ||
want: `{ | ||
petType: "Pet"; | ||
name: string; | ||
} & (Omit<components["schemas"]["Cat"], "petType"> | Omit<components["schemas"]["Dog"], "petType">)`, | ||
want: `components["schemas"]["Cat"] | components["schemas"]["Dog"]`, | ||
options: { | ||
path: "#/components/schemas/Pet", | ||
ctx: { | ||
|
@@ -313,9 +305,7 @@ describe("composition", () => { | |
given: { | ||
oneOf: [{ $ref: "#/components/schemas/parent" }, { type: "null" }], | ||
}, | ||
want: `{ | ||
operation: "schema-object"; | ||
} & (Omit<components["schemas"]["parent"], "operation"> | null)`, | ||
want: `components["schemas"]["parent"] | null`, | ||
options: { | ||
...DEFAULT_OPTIONS, | ||
ctx: { | ||
|
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.
Nice addition 👍