Skip to content

feat(jackson3): add jackson3 support for Java Client generator - WebClient - #23031

Merged
wing328 merged 5 commits into
OpenAPITools:masterfrom
phoval:feature/java_jackson3_webclient
Mar 9, 2026
Merged

wing328 merged 5 commits into
OpenAPITools:masterfrom
phoval:feature/java_jackson3_webclient

Conversation

@phoval

@phoval phoval commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

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 || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #22294" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Adds Jackson 3 support to the Java WebClient generator with Spring Boot 4, using Spring’s Jackson 3 codecs and Jakarta EE. Includes a new Petstore sample with Maven CI (Java 17/21) and adds it to the JDK17 samples workflow.

  • New Features

    • New option: useJackson3 (requires useSpringBoot4; incompatible with openApiNullable).
    • Auto-enables Jakarta EE when useSpringBoot4 is true.
    • WebClient switches between Jackson 2 (ObjectMapper + Jackson2JsonEncoder/Decoder) and Jackson 3 (JsonMapper + JacksonJsonEncoder/Decoder); all Jackson imports (incl. XML) use jacksonPackage.
    • Dependencies: add jackson-core/databind from Jackson 3; keep com.fasterxml jackson-annotations with its own version; remove jackson-jaxrs-json-provider. Versions align with Spring Boot 4.0.3 (or 3.5.11 without Spring Boot 4), Jakarta Annotations 3.0.0, Swagger annotations 1.6.16/2.2.43. Non-Jackson3 samples use Jackson 2.21.1 with separate jackson-annotations.
    • New webclient-springBoot4-jackson3 config and Petstore sample; added to samples JDK17 workflow and sample Maven CI (Java 17/21).
  • Bug Fixes

    • Restored FindBugs JSR 305 dependency to retain nullability annotations.

Written for commit 726f6c6. Summary will update on new commits.

@phoval phoval changed the title Feature/java jackson3 webclient feat(jackson3): add jackson3 support for Java Client generator - WebClient Feb 22, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 issues found across 860 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="samples/client/petstore/java/restclient-springBoot4-jackson2/docs/FakeApi.md">

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/docs/FakeApi.md:1007">
P2: The generated example uses `Arrays.asList(-efg)`, which is invalid Java syntax. The enum value "-efg" maps to `EnumClass._EFG`, so the example should reference the enum constant instead of the raw token.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/restclient/pom.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/restclient/pom.mustache:351">
P2: When useJackson3 is enabled, the template still includes jackson-databind-nullable, which depends on Jackson 2 (com.fasterxml.jackson.*). This will conflict with Jackson 3’s tools.jackson.* packages and can cause compilation/runtime failures. Guard this dependency for Jackson 3 or provide a compatible alternative.</violation>
</file>

<file name="samples/client/petstore/java/restclient-springBoot4-jackson2/README.md">

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/README.md:100">
P2: README example uses `HttpStatusCodeException` without importing it, so the snippet won’t compile when copied.</violation>
</file>

<file name="samples/client/petstore/java/restclient-springBoot4-jackson2/build.sbt">

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/build.sbt:1">
P2: Invalid comment syntax in build.sbt; '#' is not a Scala comment and will cause sbt parsing to fail.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache:169">
P2: Jackson 3 createDefaultMapper omits JsonNullableModule registration, so openApiNullable types won’t serialize/deserialize correctly.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache:195">
P2: Jackson3 createDefaultMapper builds a JsonMapper without registering JsonNullableModule when openApiNullable is enabled, unlike the Jackson2 branch. JsonNullable requires its module to be registered to serialize/deserialize nullable fields, so Jackson3-generated clients will mishandle JsonNullable values.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@phoval
phoval force-pushed the feature/java_jackson3_webclient branch 2 times, most recently from 4b3e61f to 3cdbb71 Compare March 6, 2026 07:36
@phoval
phoval force-pushed the feature/java_jackson3_webclient branch 5 times, most recently from 7fea6c1 to 22e948f Compare March 7, 2026 07:56
@phoval
phoval force-pushed the feature/java_jackson3_webclient branch from 2d6a1df to f03bda6 Compare March 7, 2026 19:06
@phoval
phoval force-pushed the feature/java_jackson3_webclient branch from f03bda6 to 726f6c6 Compare March 7, 2026 19:16
@wing328
wing328 merged commit 0d2ff8c into OpenAPITools:master Mar 9, 2026
111 checks passed
@wing328 wing328 added this to the 7.21.0 milestone Mar 9, 2026
davidricodias pushed a commit to davidricodias/openapi-generator that referenced this pull request Mar 11, 2026
…lient (OpenAPITools#23031)

* feat(jackson3): add jackson3 support for Java Client generator - WebClient

* chore: generate bin/generate-samples.sh bin/configs/java-*

* fix: add back FindBugs JSR 305 dependency

* chore: generate bin/generate-samples.sh bin/configs/java-*

* chore: generate bin/generate-samples.sh bin/configs/java-*
@timonrieger timonrieger mentioned this pull request Jun 2, 2026
3 tasks done
wing328 pushed a commit that referenced this pull request Oct 23, 2026
…rix entries (#25378)

Several samples-*.yaml workflows had path filters that did not line up with
the sample directories their matrix builds. Each line was traced in git
history; none of them was deliberate.

- samples-kotlin-client.yaml: the push trigger has used `branches:` instead
  of `paths:` since the file was created in #11619, so the workflow never ran
  on push (noted but left alone in #23007). Also add filters for the
  kotlin-jvm-okhttp-path-comments (#20767) and echo_api
  kotlin-jvm-spring-3-* (#17664) samples that are already in the matrix.
- samples-spring.yaml: samples/openapi3/client/petstore/spring* has been in
  the matrix since #11441 but was never in the filter, so changes to those
  seven samples did not trigger the workflow.
- samples-java-client-jdk17.yaml: add filters for the plain restclient
  sample (#18522, not matched by restclient-*) and webclient-springBoot4-*
  (#23031), both of which are in the matrix.
- samples-java-client-jdk11.yaml: drop two filters for
  samples/client/others/java/{resteasy,apache-httpclient}, which do not
  exist (#22003 meant samples/client/petstore/java/..., already covered by
  samples/client/petstore/java/**), and add the missing filter for
  echo_api/java/okhttp-gson-user-defined-templates (#18423).
- samples-java-client-echo-api-jdk8.yaml: restore resttemplate in the
  pull_request filter; #17473 replaced that line instead of adding to it.
- samples-kotlin-server-jdk17.yaml, samples-kotlin-server-jdk21.yaml: add the
  kotlin-misk filter for the matrix entry added in #20885.
- samples-protobuf.yaml: add the protobuf-schema-config-complex filter for
  the matrix entry added in #20915.
- samples-rust-client.yaml: the push filter pointed at the nonexistent
  samples/client/petstore/rust-server (typo introduced in #16143); use
  samples/client/petstore/rust like the pull_request filter and the matrix.
- samples-dotnet8.yaml: drop filters for csharp/httpclient/net8 and
  csharp/unityWebRequest/net8, directories that have never existed (#20270).
- samples-typescript-nestjs-server.yaml: drop the reference to a workflow
  file that does not exist (#22960); the sample it was meant for lives under
  typescript-nestjs-server/builds/parameters and is already covered.
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.

2 participants