Skip to content
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

[BUG] [typescript-fetch] oneOf models are generated without ...ToJSONTyped functions but models referencing still try to import #19858

Closed
5 of 6 tasks
joshasharpe opened this issue Oct 14, 2024 · 0 comments · Fixed by #20046

Comments

@joshasharpe
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output? below
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When an object includes a field that is a oneOf type, the generation of the oneOf does not include ...ToTypedJson method but the parent object attempts to import it still.

openapi-generator version

7.9.0

OpenAPI declaration file content or url

Small yaml that can produce
https://gist.github.com/joshasharpe/33ae2391c163f3db78f56e57ccf6d8dd

Generation Details

typescript-fetch with docker main

Steps to reproduce
  1. Create a small openapi yaml that includes one model as the parent object.
  2. Create models that will be unioned for the field
  3. Mark them as oneOf for that field
  4. Use typescript-fetch generator to create typescript code.
Related issues/PRs

Simliar to:

Suggest a fix

Adding to this file,

https://github.com/hagis/openapi-generator/blob/c36df78cff1142615f478b06d1274ccf565586cd/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache#L105

I am not sure if it is 1:1 or whether there are other functions missing. I did not see documentation explaining that this was intentional. If so, we would have to make the import conditional on whether the "child" model is oneOf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant