Skip to content

[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

Conversation

Philzen
Copy link
Contributor

@Philzen Philzen commented May 31, 2024

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

  • Read the contribution guidelines.
  • 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.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    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.
  • File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@Philzen Philzen marked this pull request as ready for review May 31, 2024 22:58
@wing328 wing328 changed the title [JAVE: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON [JAVA: okhttp-gson, rest-assured, retrofit2] Don't generate Jackson import when serialization library is GSON Jun 1, 2024
@wing328 wing328 added this to the 7.7.0 milestone Jun 1, 2024
@wing328
Copy link
Member

wing328 commented Jun 1, 2024

please resolve the conflicts when you've time

cc @ChaosMarc - author of the previous commit partially reverted by this PR

@Philzen Philzen force-pushed the bugfix/18515-jackson-dependency-in-okhttp-gson branch from 0dd31ab to f1f52d7 Compare June 2, 2024 10:06
Philzen added 2 commits June 2, 2024 12:19
…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.
@Philzen Philzen force-pushed the bugfix/18515-jackson-dependency-in-okhttp-gson branch from f1f52d7 to 130d369 Compare June 2, 2024 10:26
@Philzen Philzen force-pushed the bugfix/18515-jackson-dependency-in-okhttp-gson branch from 130d369 to 5df41f4 Compare June 2, 2024 10:31
@Philzen
Copy link
Contributor Author

Philzen commented Jun 2, 2024

@wing328 conflicts resolved, ready for merge 🚀

@wing328 wing328 merged commit ed2aad6 into OpenAPITools:master Jun 2, 2024
85 checks passed
jaxalo pushed a commit to padoa/openapi-generator that referenced this pull request Jun 3, 2024
…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
welshm pushed a commit to welshm/openapi-generator that referenced this pull request Jun 5, 2024
…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
@ChaosMarc
Copy link
Contributor

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)

Though GSON is in maintenance mode, the implementation in question has recently been committed to: ... – so IMHO for GSON fanfolks this import should still be fine.

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.

@Philzen
Copy link
Contributor Author

Philzen commented Jun 13, 2024

@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 okhttp-gson.

This PR only reverted the change for those, when using any other generator, RFC3339DateFormat is still Jackson-based as you introduced it in 76560e3.

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?

@ChaosMarc
Copy link
Contributor

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 👍

@Philzen Philzen deleted the bugfix/18515-jackson-dependency-in-okhttp-gson branch November 7, 2024 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Jackson dependency required when okhttp-gson is choosen
3 participants