-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fixes incorrect Jackson imports in Java templates used in ApiClient.java when useJakartaEe=true #18507
Fixes incorrect Jackson imports in Java templates used in ApiClient.java when useJakartaEe=true #18507
Conversation
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
… to import. This also removes the import on the apache-httpclient template where it doesn't actually get used, requiring users to declare additional dependencies for compilation that aren't actually required by the generated code other than for import.
442ccf1
to
c237671
Compare
Thanks for the heads-up @wing328 -- incorrect git config on my part. Should be fixed now 🙂 |
@wing328 sorry for the poke, but is there anything else that needs to be done or can this be merged? |
I need this too. Please merge and create a new release when possible. |
@JochemKuijpers thanks for the PR. I'll run some tests and try to get it merged before the upcoming v7.6.0 release. |
tested locally and the output compiles (except |
…ava when useJakartaEe=true (OpenAPITools#18507) * Adds useJakartaEe condition to select the appropriate Jackson package to import. This also removes the import on the apache-httpclient template where it doesn't actually get used, requiring users to declare additional dependencies for compilation that aren't actually required by the generated code other than for import. * Ran generate-samples.sh
I think this change might have broken Jakarta EE 8 support. Setting |
Hi @AdrianDiemerDev, this change has been merged back in May. If you experience any problems with this change or any current behavior of the project, I'd recommend opening a new issue. However to quickly comment on your issue: it sounds like you're running into the intended behavior of If you relied on the previous incorrect behavior of using But the Jakarta/Javax transition has been a mess, so I understand your frustration. To avoid turning this merged PR into a troubleshooting thread, please open a new issue here if you continue to have problems with this change. Feel free to mention me there and I'll see if I can help out. |
Hi, thanks for the quick reply. Yes, I'm aware of the functionality of that switch as well as the trouble with the package renaming. However, it seems that on my side, setting useJakartaEe to false doesn't have the indended effect anymore when using the generator in version 7.6.0 or newer. If I find the time to investigate more, I'll create a new issue with further details. |
Ah, now I get your confusion... I mixed up true and false in my first comment. I'm sorry! |
This PR aims to fix a compiler issue I ran into when generating
java
code from an API spec.The generated code imports
com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
inApiClient.java
, which is the javax package, while my project uses jakarta and requirescom.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider
. Upon searching, this seems to be a long-standing issue in this specific configuration, I was able to find at least one issue directly referencing it: #15875.Upon digging deeper, it seems the generated
ApiClient.java
file in my particular configuration (using theapache-httpclient
library) doesn't even use the imported class, so in this specialized template it can even be omitted, as is the case in a secondary issue reported as #18289.The PR does not add any new template parameters, but instead switches over the
useJakartaEe
parameter already exposed to select the appropriate Jackson package to import. This should fix this problem for all Java templates. In addition, I have removed the unused import for theapache-httpclient
specifically, since it is not needed.Tagging committee members as requested in the checklist:
@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg
I can currently work around the compile issue in my project through an overwritten template file in my template folder where I've fixed this locally, but this PR should fix it for everyone else running into the same issue.
PR checklist
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
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)