-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[JAVA: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON #18811
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
[JAVA: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON #18811
Conversation
please resolve the conflicts when you've time cc @ChaosMarc - author of the previous commit partially reverted by this PR |
0dd31ab
to
f1f52d7
Compare
…penAPITools#17052)" This partially reverts commit 76560e3, namely anything related to generators and samples using GSON instead of Jackson. Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat are not being reverted.
f1f52d7
to
130d369
Compare
- use fluent assertions - use helper method newTempFolder() - use Java 9 static factory methods for maps - don't declare variables that are only used once - group declarations and usages - use non-blocking java.nio.file API wherever possible
130d369
to
5df41f4
Compare
@wing328 conflicts resolved, ready for merge 🚀 |
…mport when serialization library is GSON (OpenAPITools#18811) * Partially revert "replace deprecated ISO8601Utils with StdDateFormat (OpenAPITools#17052)" This partially reverts commit 76560e3, namely anything related to generators and samples using GSON instead of Jackson. Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat are not being reverted. * Test for default serialization library fallback * Convert repetitive tests to parameterized test * Add regression test for OpenAPITools#18515 * [FEIGN] Only include <jackson-databind-version> property in pom.xml when required * [RETROFIT2] Only include jackson-databind in gradle file when actually required * [FEIGN] Don't include jackson dep's in sbt file when GSON is selected * [FEIGN] Don't include jackson dep's in gradle file when GSON is selected * DRY refactor JavaClientCodegen test code, increase readability - use fluent assertions - use helper method newTempFolder() - use Java 9 static factory methods for maps - don't declare variables that are only used once - group declarations and usages - use non-blocking java.nio.file API wherever possible * Regenerate samples
…mport when serialization library is GSON (OpenAPITools#18811) * Partially revert "replace deprecated ISO8601Utils with StdDateFormat (OpenAPITools#17052)" This partially reverts commit 76560e3, namely anything related to generators and samples using GSON instead of Jackson. Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat are not being reverted. * Test for default serialization library fallback * Convert repetitive tests to parameterized test * Add regression test for OpenAPITools#18515 * [FEIGN] Only include <jackson-databind-version> property in pom.xml when required * [RETROFIT2] Only include jackson-databind in gradle file when actually required * [FEIGN] Don't include jackson dep's in sbt file when GSON is selected * [FEIGN] Don't include jackson dep's in gradle file when GSON is selected * DRY refactor JavaClientCodegen test code, increase readability - use fluent assertions - use helper method newTempFolder() - use Java 9 static factory methods for maps - don't declare variables that are only used once - group declarations and usages - use non-blocking java.nio.file API wherever possible * Regenerate samples
I'm a little late to the party, but I nevertheless wanted to share my thoughts. The problem with adding jackson as a dependency to gson-only builds is something I tried to adress in one of my responses (#17052 (comment)) but obviously couldn't express myself clearly enough that I also think that it's a bad idea. What I didn't realize was that it would lead to compile errors 🫣 sorry for that! @Philzen you wrote in #18515 (comment)
My problem with using that class was not that it's no longer maintained but that it's in an internal package that is not exposed through osgi. IMHO it's bad practice to use internal classes because they (propably) are internal for a reason. To use the class in other osgi modules you have to add (compileInclude) the dependency to every module that uses it instead of just deploying it to the osgi runtime container once and reference (implementation) it in the other modules' manifest. |
@ChaosMarc i wasn't aware of OSGi at all before your post, learning something new every day… cheers. Sounds important to consider for professional industry applications, so i get you. This is now a classical target conflict, as on the other side at least two users, @winrid and @efren1villamagua have raised issues with having a Jackson dependency suddenly appearing in their stack. Although i personally just migrated a huge project away from GSON over to Jackson, becoming a huge fan along the way, i absolutely share the expectation that i'd get a GSON-only stack when using This PR only reverted the change for those, when using any other generator, My take would be that if you work in an environment where OSGi is a thing, you probably wouldn't use GSON in the first place, and OpenApiGenerator generators come with a plethora of non-GSON flavours. What do you think? |
Hey @Philzen, thanks for reading about OSGi. It most definitely has it's use cases in modern systems even though it is around for quite a long time. When I started my current project we went with okhttp-gson because 1. it's the default, 2. we already had okhttp in place and 3. I personally like gson very much. But with the internal classes problem at hand and the fact that the okhttp team also struggles to keep their builds working with OSGi, I agree with you and will refrain from using this particular generator in future OSGi-based projects. I will propably go with "native" instead, which was not an option as we started out with java 8 and only recently upgraded to 11. As my current project sadly has been canceled and will be killed alltogether, we will just go with my workaround of providing the internal classes in a custom osgi module ourselves (see julman99/gson-fire#52 (comment)) until we're shut down for good 😅 Thanks again for fixing the mess I've created with my previous PR and having such a good natured conversation about the whole topic with me 👍 |
This partially reverts commit 76560e3, namely anything related to generators and samples using GSON instead of Jackson.
Changes to Jackson-only generation and generator-online regarding RFC3339DateFormat are not being reverted.
Resolves #18515
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.6.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)