-
-
Notifications
You must be signed in to change notification settings - Fork 528
fix incorrect types generated when refs reference types with discriminators #1289
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
fix incorrect types generated when refs reference types with discriminators #1289
Conversation
🦋 Changeset detectedLatest commit: 76f092f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
90c98a4
to
2720165
Compare
It also looks related to #1116 |
Test macos failed, because the digital ocean test timed out. I'm pretty sure it's got nothing to do with this change... I observed this test being quite slow locally as well, on the main branch |
Looks great to me! But just replace that deleted test to ensure this is working correctly. Also yeah I should probably just disable DigitalOcean in the macOS test. It’s gotten worse as DigitalOcean’s API has gotten even bigger from when the test was originally added. It’s not a macOS issue; it’s an issue with the limited resources on the slow macOS runner in GitHub Actions. I think it’d be safe to assume if other tests pass in macOS, it’s safe. Ignore in your PR though; I’ll merge it even if that macOS test times out. |
7b2caa4
to
76f092f
Compare
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.
Awesome work! 👏 Thank you
Just a heads up: In reviewing issues I realized #1158 does outline a bug that results in slightly-altered typegen in one of the tests added: - components["schemas"]["parent"] | null
+ {
+ operation: "schema-object";
+ } & (components["schemas"]["parent"] | null) This seems weird, but I believe the discriminator spec does suggest that if It’s weird, but seems to be how it’s outlined 🤷. Anyways that shouldn’t cause a regression in this fix at all; just wanted to flag an incoming change. |
Changes
This PR fixes the code, so that incorrect types are not generated when referencing a type (with a discriminator with an implicit mapping) inside a oneOf/anyOf
How to Review
I added tests to both
index.test.ts
andschema-object.test.ts
, and I tried to fix the code, but I must admit it was kind of a shot in the dark, but it does seem to work :)Checklist
docs/
updated (if necessary)pnpm run update:examples
run (only applicable for openapi-typescript) (I ran this but nothing changed)