Skip to content

Comments

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

Open
phoval wants to merge 13 commits intoOpenAPITools:masterfrom
phoval:feature/java_jackson3_webclient
Open

feat(jackson3): add jackson3 support for Java Client generator - WebClient#23031
phoval wants to merge 13 commits intoOpenAPITools:masterfrom
phoval:feature/java_jackson3_webclient

Conversation

@phoval
Copy link

@phoval phoval commented Feb 22, 2026

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 client generator for Spring Boot 4, covering both WebClient and RestTemplate libraries. Introduces a new useJackson3 option, updates templates and docs, and adds Spring Boot 4 sample configs.

  • New Features

    • New additionalProperty: useJackson3 (requires useSpringBoot4, incompatible with openApiNullable).
    • WebClient and RestTemplate ApiClient templates now switch imports and runtime components based on Jackson 2 vs 3, including XML converters when enabled.
    • POM templates updated to emit correct Jackson 3 coordinates and Spring Boot 4 compatible dependencies.
    • New sample configs:
      • java-restclient-springBoot4-jackson2.yaml
      • java-restclient-springBoot4-jackson3.yaml
      • java-webclient-springBoot4-jackson3.yaml
    • Docs updated (java.md, java-microprofile.md) to document useJackson3.
    • Misc: RFC3339DateFormat and model templates now use a configurable jacksonPackage; sample builds bump to newer Maven plugins; dev shell uses JDK 17.
  • Migration

    • To generate Jackson 3 clients: set useSpringBoot4=true and useJackson3=true.
    • Do not enable openApiNullable with Jackson 3.
    • Build with Java 17+.

Written for commit 1a7c61b. 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
Copy link
Contributor

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

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.

String enumQueryString = "_abc"; // String | Query parameter enum test (string)
Integer enumQueryInteger = 1; // Integer | Query parameter enum test (double)
Double enumQueryDouble = 1.1D; // Double | Query parameter enum test (double)
List<EnumClass> enumQueryModelArray = Arrays.asList(-efg); // List<EnumClass> |
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

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.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/restclient-springBoot4-jackson2/docs/FakeApi.md, line 1007:

<comment>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.</comment>

<file context>
@@ -0,0 +1,1541 @@
+        String enumQueryString = "_abc"; // String | Query parameter enum test (string)
+        Integer enumQueryInteger = 1; // Integer | Query parameter enum test (double)
+        Double enumQueryDouble = 1.1D; // Double | Query parameter enum test (double)
+        List<EnumClass> enumQueryModelArray = Arrays.asList(-efg); // List<EnumClass> | 
+        List<String> enumFormStringArray = Arrays.asList("$"); // List<String> | Form parameter enum test (string array)
+        String enumFormString = "_abc"; // String | Form parameter enum test (string)
</file context>
Fix with Cubic

{{#useSpringBoot4}}
<spring-web-version>7.0.5</spring-web-version>
{{#useJackson3}}
<jackson-version>3.0.4</jackson-version>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

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.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/Java/libraries/restclient/pom.mustache, line 351:

<comment>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.</comment>

<file context>
@@ -341,25 +331,42 @@
+        {{#useSpringBoot4}}
+        <spring-web-version>7.0.5</spring-web-version>
+        {{#useJackson3}}
+        <jackson-version>3.0.4</jackson-version>
+        {{/useJackson3}}
+        {{^useJackson3}}
</file context>
Fix with Cubic

try {
Client result = apiInstance.call123testSpecialTags(client);
System.out.println(result);
} catch (HttpStatusCodeException e) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

P2: README example uses HttpStatusCodeException without importing it, so the snippet won’t compile when copied.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/restclient-springBoot4-jackson2/README.md, line 100:

<comment>README example uses `HttpStatusCodeException` without importing it, so the snippet won’t compile when copied.</comment>

<file context>
@@ -0,0 +1,278 @@
+        try {
+            Client result = apiInstance.call123testSpecialTags(client);
+            System.out.println(result);
+        } catch (HttpStatusCodeException e) {
+            System.err.println("Exception when calling AnotherFakeApi#call123testSpecialTags");
+            System.err.println("Status code: " + e.getStatusCode().value());
</file context>
Fix with Cubic

@@ -0,0 +1 @@
# TODO
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

P2: Invalid comment syntax in build.sbt; '#' is not a Scala comment and will cause sbt parsing to fail.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/restclient-springBoot4-jackson2/build.sbt, line 1:

<comment>Invalid comment syntax in build.sbt; '#' is not a Scala comment and will cause sbt parsing to fail.</comment>

<file context>
@@ -0,0 +1 @@
+# TODO
</file context>
Fix with Cubic

public static ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) {
{{#useJackson3}}
public static JsonMapper createDefaultMapper(@Nullable DateFormat dateFormat) {
return JsonMapper.builder()
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

P2: Jackson 3 createDefaultMapper omits JsonNullableModule registration, so openApiNullable types won’t serialize/deserialize correctly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache, line 169:

<comment>Jackson 3 createDefaultMapper omits JsonNullableModule registration, so openApiNullable types won’t serialize/deserialize correctly.</comment>

<file context>
@@ -150,7 +164,21 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
-    public static ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) {
+    {{#useJackson3}}
+    public static JsonMapper createDefaultMapper(@Nullable DateFormat dateFormat) {
+        return JsonMapper.builder()
+            .defaultDateFormat(dateFormat)
+            {{#failOnUnknownProperties}}
</file context>
Fix with Cubic

{{^failOnUnknownProperties}}
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
{{/failOnUnknownProperties}}
.build();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 22, 2026

Choose a reason for hiding this comment

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

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.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache, line 195:

<comment>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.</comment>

<file context>
@@ -159,7 +182,21 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
+            {{^failOnUnknownProperties}}
+            .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+            {{/failOnUnknownProperties}}
+            .build();
+    }
+    {{/useJackson3}}
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants