-
-
Notifications
You must be signed in to change notification settings - Fork 540
Referencing a type with discriminator generates wrong type #1116
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
Comments
+1 |
Could you provide a full example of a schema? So we can reproduce this |
The example is in my fork:
|
I actually think the generated types are correct. From the spec:
In other words, the mapping is optional, and the spec allows for implicit mapping, of which As a workaround you could shorten your schema to: Owner:
type: object
properties:
favoritePet:
$ref: "#/components/schemas/Pet" Which would produce favoritePet?: components["schemas"]["Pet"]; The only difference being the missing If I’m mistaken, then please take a look at this existing |
Going to close this issue as I believe this is working as intended (the definition of discriminators is just tricky). But again, open to feedback if I’m mistaken in this. |
You're right. I'm not sure why our Micronaut BE generates this schema:
instead of this:
I'll try to fix the BE then. |
Uh oh!
There was an error while loading. Please reload this page.
Description
When adding an
Owner
type that references aPet
indiscriminator (oneOf)
test case like so:the generated type is wrong:
instead of
openapi-typescript
6.2.4
Reproduction
See PR: sregg#1
Expected result
See error message in: https://github.com/sregg/openapi-typescript/actions/runs/5009218680/jobs/8977922547?pr=1
Checklist
The text was updated successfully, but these errors were encountered: