[java][webclient] Jackson3 support for webclient#23072
[java][webclient] Jackson3 support for webclient#23072robinmarechal wants to merge 3 commits intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
6 issues found across 224 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 (unresolved 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="modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache:126">
P2: Using Jackson 3 with openApiNullable pulls in jackson-databind-nullable 0.2.9, which only provides the Jackson 2 module (JsonNullableModule). The generated ApiClient uses JsonNullableJackson3Module under useJackson3, so the code will not compile.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache:202">
P2: Spring Boot 4.x (Jakarta-based) is configured in the useJakartaEe=false block, which is intended for legacy javax compatibility. This makes the non-Jakarta configuration incompatible with its own goal and will break builds expecting javax.* APIs.</violation>
</file>
<file name="samples/client/petstore/java/webclient-jackson3/build.gradle">
<violation number="1" location="samples/client/petstore/java/webclient-jackson3/build.gradle:123">
P2: `jackson_databind_version` is assigned twice; the second assignment overwrites the intended Jackson 3 version with 2.19.2, causing the `tools.jackson.core:jackson-databind` dependency to resolve to a non-existent/incorrect version.</violation>
</file>
<file name="samples/client/petstore/java/webclient-jackson3/build.sbt">
<violation number="1" location="samples/client/petstore/java/webclient-jackson3/build.sbt:1">
P2: Invalid `#` comment syntax in build.sbt will cause sbt to fail parsing the build file.</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache:162">
P2: jackson_databind_version is set to 3.1.0 for useJackson3, but an unconditional assignment to 2.19.2 later in the file overwrites it, so the Jackson 3 dependency block still uses the 2.x version.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache:194">
P2: openApiNullable pulls in Jackson 2 (jackson-databind-nullable) even when useJackson3 switches to tools.jackson dependencies, leading to a mixed Jackson 2/3 classpath and broken JsonNullable support.</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.
| {{/useJackson3}} | ||
| {{#useJackson3}} | ||
| <dependency> | ||
| <groupId>tools.jackson.core</groupId> |
There was a problem hiding this comment.
P2: Using Jackson 3 with openApiNullable pulls in jackson-databind-nullable 0.2.9, which only provides the Jackson 2 module (JsonNullableModule). The generated ApiClient uses JsonNullableJackson3Module under useJackson3, so the code will not compile.
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/pom.mustache, line 126:
<comment>Using Jackson 3 with openApiNullable pulls in jackson-databind-nullable 0.2.9, which only provides the Jackson 2 module (JsonNullableModule). The generated ApiClient uses JsonNullableJackson3Module under useJackson3, so the code will not compile.</comment>
<file context>
@@ -114,11 +114,20 @@
+ {{/useJackson3}}
+ {{#useJackson3}}
+ <dependency>
+ <groupId>tools.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson-databind-version}</version>
</file context>
There was a problem hiding this comment.
OpenAPITools/jackson-databind-nullable#117 required to fix this
| <spring-boot-version>3.2.12</spring-boot-version> | ||
| {{/useJackson3}} | ||
| {{#useJackson3}} | ||
| <spring-boot-version>4.0.3</spring-boot-version> |
There was a problem hiding this comment.
P2: Spring Boot 4.x (Jakarta-based) is configured in the useJakartaEe=false block, which is intended for legacy javax compatibility. This makes the non-Jakarta configuration incompatible with its own goal and will break builds expecting javax.* APIs.
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/pom.mustache, line 202:
<comment>Spring Boot 4.x (Jakarta-based) is configured in the useJakartaEe=false block, which is intended for legacy javax compatibility. This makes the non-Jakarta configuration incompatible with its own goal and will break builds expecting javax.* APIs.</comment>
<file context>
@@ -167,19 +183,35 @@
<spring-boot-version>3.2.12</spring-boot-version>
+ {{/useJackson3}}
+ {{#useJackson3}}
+ <spring-boot-version>4.0.3</spring-boot-version>
+ {{/useJackson3}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
</file context>
| <spring-boot-version>4.0.3</spring-boot-version> | |
| <spring-boot-version>2.7.17</spring-boot-version> |
| @@ -0,0 +1 @@ | |||
| # TODO | |||
There was a problem hiding this comment.
P2: Invalid # comment syntax in build.sbt will cause sbt to fail parsing the build file.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/webclient-jackson3/build.sbt, line 1:
<comment>Invalid `#` comment syntax in build.sbt will cause sbt to fail parsing the build file.</comment>
<file context>
@@ -0,0 +1 @@
+# TODO
</file context>
modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
1 issue found across 20 files (changes from recent commits).
Prompt for AI agents (unresolved 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="modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache:121">
P2: openApiNullable still adds jackson-databind-nullable (Jackson 2) even when useJackson3 is enabled, creating a Jackson 2/3 dependency mismatch that breaks generated clients. Guard openApiNullable for Jackson 3 or use a Jackson 3–compatible nullable module.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>${jackson-databind-version}</version> | ||
| <version>${jackson-version}</version> |
There was a problem hiding this comment.
P2: openApiNullable still adds jackson-databind-nullable (Jackson 2) even when useJackson3 is enabled, creating a Jackson 2/3 dependency mismatch that breaks generated clients. Guard openApiNullable for Jackson 3 or use a Jackson 3–compatible nullable module.
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/pom.mustache, line 121:
<comment>openApiNullable still adds jackson-databind-nullable (Jackson 2) even when useJackson3 is enabled, creating a Jackson 2/3 dependency mismatch that breaks generated clients. Guard openApiNullable for Jackson 3 or use a Jackson 3–compatible nullable module.</comment>
<file context>
@@ -118,14 +118,14 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>${jackson-databind-version}</version>
+ <version>${jackson-version}</version>
</dependency>
{{/useJackson3}}
</file context>
Add Jackson 3 support to webclient.
Equivalent of #23071 for webclient, integrating some of the changes made in it for native client.
Added
useJackson3option, with defaultfalseto keep using jackson 2 as a default.Note : Annotations do not move with jackson 3. Therefore
import com.fasterxml.jackson.annotationdo not change.ApiClient:useJackson3to import either jackson 3 or jackson 2 classesJsonMapper.builder()to create default object mapperObjectMapperinstead ofJsonMapperto simplify jackson 2/3 interoperability in mustache fileJsonProcessingExceptionanymore. Jackson3's object mapper now throwsJacksonExceptionwhich is already aRuntimeException.fixes #22294
Ideally, OpenAPITools/jackson-databind-nullable#117 would be merged before so I can update its version in maven/gradle dependencies. But it can also be done afterwards.
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 #123"present in the PR description)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)
Summary by cubic
Adds optional Jackson 3 support to the Java WebClient generator via the useJackson3 flag, keeping Jackson 2 as the default. Also standardizes and fixes Jackson dependency coordinates/versions in Gradle/Maven templates and samples. Fixes #22294.
New Features
Migration
Written for commit e25ba6a. Summary will update on new commits.