[BUG] [typescript-fetch] oneOf models are generated without `...ToJSONTyped` functions but models referencing still try to import
Bug Report Checklist
- [X] Have you provided a full/minimal spec to reproduce the issue?
- [X] Have you validated the input using an OpenAPI validator (example)?
- [X] Have you tested with the latest master to confirm the issue still exists?
- [X] Have you searched for related issues/PRs?
- [X] 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
- Create a small openapi yaml that includes one model as the parent object.
- Create models that will be unioned for the field
- Mark them as oneOf for that field
- Use
typescript-fetchgenerator to create typescript code.
Related issues/PRs
Simliar to:
- https://github.com/OpenAPITools/openapi-generator/issues/15736
- https://github.com/OpenAPITools/openapi-generator/pull/19524
- https://github.com/OpenAPITools/openapi-generator/issues/14763 (This is still open so I almost posted here but it does not directly mention this particular function missing)
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.