-
-
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
remove unused import org.openapitools.jackson.nullable.JsonNullable from generated model #2901
Comments
This issue is affecting us as well. Is there an ETA for fixing this? Alternatively, is there a workaround by which we dont need to include the dependency? |
What about using customized template with the |
Thank you for your response @wing328 . Could you please elaborate on what you meant? Do you mean i could create a custom template that does not include the dependency and use the template while building? (I use open-api generator maven plugin) |
This affect my project as well. |
@wing328 can you please tell me which template is it? I create PR with fix. |
as workaround while new version is published create directory |
you could also post-process the generated files with a script and remove the unused import by search/replace. |
bug still there in generator 4.1.3 |
I agree with @macjohnny, post processing the generated file might be a temporary valid solution, but you do not need to do it by hand. In #3461 (comment) I have indicated the google-java-format project that can do this (there are gradle and maven plugins). In my main project I rely on Eclipse IDE tasks (format code and organize imports) to do it (but there OpenAPI-Generator is used inside a custom plugin) About the root issue: I see you are using the A possible way to solve this issue without post-processing step is to understand what is different between the two generators (templates or logic in the code-gen layer) and to align them. |
Yeah, the imports are only added when necessary, so it should also be possible to only put this dependency in pom.xml iff it's imported at least once somewhere. The patch to do that shouldn't be too hard, but unfortunately I don't have any spare time ATM - if someone wants to work on that, I'd be happy to provide guidance though. |
@nikodemin this issue will not magically disappear as long as there is no one that wants to contribute a fix. |
@macjohnny : Yes, you're right. But what should we do ? Today, it's the second times I'm in the same situation as @pellyadolfo describe in his first comment :
Maybe, its should be a good idea to add property like I can try to work on this if you want. |
@Patouche yes, a configurable option would be nice. By the way: the dependency / code could be removed in the generated code by writing a small post-processing script, so you have a workaround. |
@Patouche have you tried https://github.com/google/google-java-format suggested by @jmini ? Of course, we can add another option but we also got feedback from users that we've too many options in some generators (e.g. Java) |
This is a problem for the vertx one too, please remove it. |
@wing328 : Yes, I took a look at https://github.com/google/google-java-format but I didn't try it because it wasn't really a solution for this bug / feature. This library is design to format java code. IMHO, the first step here is to remove the dependency to |
@Patouche Is this done? I would be happy if |
@sdoeringNew : yes, it was. Now there is some conflict on the PR. I already propose to resolve them. But I have no news for a code reviews. Maybe I did something wrong. I don't know... |
@Patouche thanks for the PR. Please PM me via Slack so that we can help move forward with your PR. |
-Adolfo Rodriguez |
Add a option for all java client and server to prevent usage of third party library (jackson-databind-nullable) which may be forbidden in some company Add samples for Vertx, Spring MVC, Spring Cloud, Feign and Play Upgrade dependencies for org.openapitools:jackson-databind-nullable
…on Nullable library (#6154) * Add option to prevent usage of jackson-nullable (#2901) Add a option for all java client and server to prevent usage of third party library (jackson-databind-nullable) which may be forbidden in some company Add samples for Vertx, Spring MVC, Spring Cloud, Feign and Play Upgrade dependencies for org.openapitools:jackson-databind-nullable * Samples - Remove dependency org.openapitools:jackson-databind-nullable (#2901) * Fix generation of gradle file for vertx (#2901) * Regenerate samples (#2901) * Fix documentation and up to date (#2901) * Fix forgotten regeneration of vertx after dependency integration (#2901) * Regenerate template after rebase (#2901) * Use yaml config files introduce in #6509 to manage samples (#2901) * Regenerate template using the config (#2901) * Fix bad version during testing generated samples (#2901) * Regenerate template after fix bad version (#2901) * Fix merge, allow for set importing on codegen model Co-authored-by: Jim Schubert <[email protected]>
Name of the new property is "openApiNullable" |
With
version: 4.3.1 |
@SausageRoll #6154 is included in 5.0.0 |
I see |
Thanks for this fix. That was the reason we could not update to v4. And now we can jump straight to v5. |
I get same error for versions 5.2.x and 5.3.x, in 5.1.x it works fine without added dependency. |
I think you need to set |
|
Bug Report Checklist
Description
When I generate the model there is an unused import org.openapitools.jackson.nullable.JsonNullable; in every single DTO. It forces me to add a dependency.
Unfortunately this dependency must be approved in the company so the model is unusable.
Is there any way to get rid of this unused import? Configuration is below:
openapi-generator version
OpenAPI declaration file content or url
probably convenient enhancement
Command line used for generation
maven plugin
Steps to reproduce
run the maven clean install
Related issues/PRs
a few similar issues
Suggest a fix
provide a mechanism to remove unused imports
The text was updated successfully, but these errors were encountered: