[FIX][typescript-fetch] Fix self import for models with a discriminator
This PR will fix issue #15637 .
In this PR the modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache file was edited, by removing the self import for the discriminator models.
To validate the work use ./bin/generate-samples.sh bin/configs/typescript-fetch-self-import-issue.yaml once with and once without the fix and compare the files it generates.
PR checklist
- [x] Read the contribution guidelines.
- [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
- [x] Run the following to build the project and update samples:
Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./mvnw clean package ./bin/generate-samples.sh ./bin/utils/export_docs_generators.sh./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH. - [x] In case you are adding a new generator, run the following additional script :
Commit all changed files../bin/utils/ensure-up-to-date - [x] File the PR against the correct branch:
master(6.3.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks) - [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Hello, is this still beeing worked on?
I just noticed that Gero did not mention the technical committee :)
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04)
Is there still being worked on? I'm having the same issue. If I build my project with the legacyDiscriminatorBehavior=false flag, I get multiple duplicate errors like this one:
@GeroSchaarmann do you want to fix the conflicts?
Any update? We have the same problem and need to remove the imports manually.
Would love to see this go though in the next milestone/version. I am currently having issues with this on a project and would love to not have to modify the generated API code at all.
I see this got moved to the next release again. Can this please be resolved in 7.6.0?
@joshuamolden you can e.g. clone this PR and fix the conflicts to move this forward
True! Didn't even think of that! I'll take a stab!
It seems like the fix would either be:
- Updating this modelGeneric.mustache file to properly account for discriminators being present
- The original author tried to modify this file, but I don't think his changes actually fixed the issue: https://github.com/OpenAPITools/openapi-generator/pull/15638#discussion_r1265614448
- Controlling the values passed to this mustache file so that it can't make duplicate imports with based on the current mustache template.
I am not sure how to go about option 2, so I think option 1 is most viable.
I noticed on my project that I had legacyDiscriminatorBehavior set to false. I switched it to true and my code didn't seem to generate with the same issues this ticket is addressing. I would rather not have to opt into the legacy behavior though, so it would still be nice to resolve this ticket.
Due to this PR not being developed any further I forked the branch and opened an updated PR here.
@macjohnny This can be closed aswell i think. (: