feat(jackson3): add jackson3 support for Java Client generator - WebClient#23031
feat(jackson3): add jackson3 support for Java Client generator - WebClient#23031phoval wants to merge 13 commits intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
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-aiwith guidance or docs links (includingllms.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> | |
There was a problem hiding this comment.
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>
| {{#useSpringBoot4}} | ||
| <spring-web-version>7.0.5</spring-web-version> | ||
| {{#useJackson3}} | ||
| <jackson-version>3.0.4</jackson-version> |
There was a problem hiding this comment.
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>
| try { | ||
| Client result = apiInstance.call123testSpecialTags(client); | ||
| System.out.println(result); | ||
| } catch (HttpStatusCodeException e) { |
There was a problem hiding this comment.
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>
| @@ -0,0 +1 @@ | |||
| # TODO | |||
There was a problem hiding this comment.
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>
| public static ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) { | ||
| {{#useJackson3}} | ||
| public static JsonMapper createDefaultMapper(@Nullable DateFormat dateFormat) { | ||
| return JsonMapper.builder() |
There was a problem hiding this comment.
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>
| {{^failOnUnknownProperties}} | ||
| .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||
| {{/failOnUnknownProperties}} | ||
| .build(); |
There was a problem hiding this comment.
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>
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(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #22294"present in the PR description)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
Migration
Written for commit 1a7c61b. Summary will update on new commits.