-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] bad import for SpringBoot model #3461
Comments
cc @cbornet |
I also saw this. It is unused import and it forces to add dependency. |
I think this issue is far bigger. In a lot of generators there are a heck of a ton unused imports in every file. My IDE really hates me for that since there are generated files which are not annotated as generated in the comments. I think the best option would be to make each single import conditional which would bloat the whole generator in its current state. Each import would be associated with one or multiple features. If one or more of those features are used the import should be set as well as other conditional events like adding the dependency to the dependency management system. |
The problem is even bigger, if you want to use the generator in build tool, after generating it does not compil witout removing that unused import, so you cannot use it in an automated build! |
I have started to add google-java-format as post-generation step when I use OpenAPI-Generator. It removes the unused imports and format the code. |
@jmini That is a good solution to start with. But that only fixes the issue for Java. Since the generator is not java specific I tend to not like that as a final solution. |
@jmini sound like a big hack. This kind of solution tends to hide problems. Why to not fix the bug as it perfectly visible and reproducible. |
@bademux: feel free to propose a PR. The problem is that the way the generator is built, the imports are written first and at this point in time the information to know if one of the field will use |
@jmini Well, it a bit of a work to propose new generator :) Closed as a "Won't fix" (until global generator context with all needed information will be passed) |
According to #3474 (comment), I think that @bkabrda added the code you wanted:
Can you test with the latest SNAPSHOT? |
The commit 0fca901 adds
`` `import org.openapitools.jackson.nullable.JsonNullable; ```
Why I need to import the class if I don't need it?
The text was updated successfully, but these errors were encountered: