Skip to content

[java][webclient] Jackson3 support for webclient#23072

Open
robinmarechal wants to merge 6 commits intoOpenAPITools:masterfrom
robinmarechal:feature/jackson3-webclient
Open

[java][webclient] Jackson3 support for webclient#23072
robinmarechal wants to merge 6 commits intoOpenAPITools:masterfrom
robinmarechal:feature/jackson3-webclient

Conversation

@robinmarechal
Copy link

@robinmarechal robinmarechal commented Feb 28, 2026

Add Jackson 3 support to webclient.
Equivalent of #23071 for webclient, integrating some of the changes made in it for native client.

Added useJackson3 option, with default false to keep using jackson 2 as a default.
Note : Annotations do not move with jackson 3. Therefore import com.fasterxml.jackson.annotation do not change.

  • Main changes are in ApiClient :
    • Use useJackson3 to import either jackson 3 or jackson 2 classes
    • Use JsonMapper.builder() to create default object mapper
    • No equivalent of JavaTimeModule since it has been included directly in jackson databind
    • Keep ObjectMapper instead of JsonMapper to simplify jackson 2/3 interoperability in mustache file
    • Change codecs to use Jackson 3 instead of jackson 2 encoder/decoder. Without specifying media type myself because Spring does a better job than us to use json-compatible media types by default (I run into errors when I tried to specify it myself as before, which were fixed when removing it)
    • No need for try/catch JsonProcessingException anymore. Jackson3's object mapper now throws JacksonException which is already a RuntimeException.

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

  • 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 #123" 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.

@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 useJackson3 (default false). Standardizes tools.jackson dependencies, updates RFC3339 handling, and adds a CI-validated sample. Fixes #22294.

  • New Features

    • Added useJackson3 to switch WebClient JSON handling to Jackson 3.
    • ApiClient uses JsonMapper and runtime JacksonException; keeps ObjectMapper type for 2/3 compatibility.
    • RFC3339 date/time uses Jackson 3 deserializers; JavaTimeModule not needed.
    • WebClient codecs use Jackson 3 encoder/decoder; rely on Spring for media-type selection.
    • Nullable uses JsonNullableJackson3Module when enabled.
    • Docs updated to note Jackson 3 support is limited to native and webclient; model templates use jacksonPackage for XML imports.
    • New webclient-jackson3 sample added and wired into the JDK17 samples workflow; unit test covers WebClient with Jackson 3.
  • Migration

    • Opt in with additionalProperties.useJackson3: true.
    • Requires Jackson 3.x (tools.jackson.*) and Spring Boot 4.x in generated projects.
    • Only supported for the native and webclient libraries in the Java generator.
    • Incompatible with openApiNullable.
    • Annotations remain under com.fasterxml.jackson.annotation.
    • No need to catch JsonProcessingException; Jackson 3 throws runtime JacksonException.
    • Templates set Spring Boot to 4.0.3 when useJackson3; dependency versions and groupIds standardized.

Written for commit 7e306e8. Summary will update on new commits.

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

{{/useJackson3}}
{{#useJackson3}}
<dependency>
<groupId>tools.jackson.core</groupId>
Copy link
Contributor

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

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

OpenAPITools/jackson-databind-nullable#117 required to fix this

Hi @robinmarechal

Great work on this contribution!

In the Spring generator, there was the same block with Openapinullable, and what was done was that, for now, useJackson3 and openapiNullable are incompatible.

I think that to unblock this PR, we could do the same thing.

What do you think @robinmarechal @wing328 ?

Copy link
Author

Choose a reason for hiding this comment

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

That's a good idea!
A just rebased onto master, someone actually did it for me in #23023 😄

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.

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>
Copy link
Contributor

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

Choose a reason for hiding this comment

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

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>
Fix with Cubic

@@ -0,0 +1,10 @@
generatorName: java
outputDir: samples/client/petstore/java/webclient-jackson3
Copy link
Member

Choose a reason for hiding this comment

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

I tested this locally with mvn integration-test -f samples/client/petstore/java/webclient-jackson3/pom.xml but got errors:

[ERROR] /C:/Users/User/code/openapi-generator/samples/client/petstore/java/webclient-jackson3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java:[28,9] method addDeserializer in class tools.jackson.databind.module.SimpleModule cannot be applied to given types;
[ERROR]   required: java.lang.Class<T>,tools.jackson.databind.ValueDeserializer<? extends T>
[ERROR]   found:    java.lang.Class<java.time.OffsetDateTime>,org.openapitools.client.RFC3339InstantDeserializer<java.time.OffsetDateTime>
[ERROR]   reason: cannot infer type-variable(s) T
[ERROR]     (argument mismatch; org.openapitools.client.RFC3339InstantDeserializer<java.time.OffsetDateTime> cannot be converted to tools.jackson.databind.ValueDeserializer<? extends T>)
[ERROR] /C:/Users/User/code/openapi-generator/samples/client/petstore/java/webclient-jackson3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java:[29,9] method addDeserializer in class tools.jackson.databind.module.SimpleModule cannot be applied to given types;
[ERROR]   required: java.lang.Class<T>,tools.jackson.databind.ValueDeserializer<? extends T>
[ERROR]   found:    java.lang.Class<java.time.ZonedDateTime>,org.openapitools.client.RFC3339InstantDeserializer<java.time.ZonedDateTime>
[ERROR]   reason: cannot infer type-variable(s) T
[ERROR]     (argument mismatch; org.openapitools.client.RFC3339InstantDeserializer<java.time.ZonedDateTime> cannot be converted to tools.jackson.databind.ValueDeserializer<? extends T>)

can you please take a look when you've time?

please also add this output folder to github workflow: https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-java-client-jdk17.yaml

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@robinmarechal robinmarechal force-pushed the feature/jackson3-webclient branch from e25ba6a to 68dc149 Compare March 6, 2026 10:57
@robinmarechal robinmarechal reopened this Mar 6, 2026
@robinmarechal
Copy link
Author

Sorry for the close/reopen, small mistake with my rebase.
PR is still WIP, I'm working on the the other changes requests and suggestions

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.

10 issues found across 215 files (changes from recent commits).

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/ApiClient.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache:13">
P2: Jackson 3 JsonMapper is in tools.jackson.databind.json, not tools.jackson.databind. This import will not resolve and generated clients will fail to compile when useJackson3=true.</violation>
</file>

<file name="samples/client/petstore/java/webclient-jackson3/.travis.yml">

<violation number="1" location="samples/client/petstore/java/webclient-jackson3/.travis.yml:8">
P2: CI matrix uses JDK 8–12, but this sample depends on Spring Boot 4.0.3 which requires Java 17+. Builds/tests will fail or be misleading on those JDKs.</violation>
</file>

<file name="samples/client/petstore/java/webclient-jackson3/docs/PetApi.md">

<violation number="1" location="samples/client/petstore/java/webclient-jackson3/docs/PetApi.md:264">
P3: The example declares a Set<String> but initializes it with Arrays.asList(), which returns a List. This snippet will not compile as written.</violation>
</file>

<file name="docs/generators/java-microprofile.md">

<violation number="1" location="docs/generators/java-microprofile.md:102">
P3: Duplicate `useJackson3` entry in the config options table provides conflicting constraints for the same option, which can mislead users and should be consolidated into a single description.</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: The new build.sbt contains a shell-style “#” comment, which is invalid Scala syntax and will cause SBT to fail parsing this build file.</violation>
</file>

<file name="samples/client/petstore/java/webclient-jackson3/git_push.sh">

<violation number="1" location="samples/client/petstore/java/webclient-jackson3/git_push.sh:48">
P2: GIT_TOKEN is embedded directly in the remote URL, which persists the token in plaintext in .git/config and exposes it in process arguments. Use credential helpers or other non-URL-based auth to avoid leaking the token.</violation>
</file>

<file name="samples/client/petstore/java/webclient-jackson3/docs/FakeApi.md">

<violation number="1" location="samples/client/petstore/java/webclient-jackson3/docs/FakeApi.md:1007">
P2: The generated Java example uses `Arrays.asList(-efg)`, which is invalid Java syntax and makes the snippet uncompilable.</violation>
</file>

<file name="samples/client/petstore/java/webclient-jackson3/build.gradle">

<violation number="1" location="samples/client/petstore/java/webclient-jackson3/build.gradle:81">
P2: Spring Boot 4.0 requires Java 17+, but this build sets source/target to Java 8, which will not compile/run with Boot 4 dependencies.</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:196">
P2: When useJackson3 is enabled, the template still always adds jackson-databind-nullable 0.2.9, which is built against Jackson 2.x. This will pull com.fasterxml.jackson.databind 2.x alongside tools.jackson 3.x, leading to classpath/API incompatibilities for openApiNullable users. Consider gating openApiNullable for Jackson3 or upgrading to a Jackson3-compatible nullable module when available.</violation>
</file>

<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:202">
P2: Non-Jakarta mode now picks Spring Boot 4.0.3 when useJackson3 is true, but non-Jakarta templates still generate javax.* imports. Spring Boot 4 is Jakarta-only, so this combination will not compile/run with the generated code and dependency versions.</violation>
</file>

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

echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

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

P2: GIT_TOKEN is embedded directly in the remote URL, which persists the token in plaintext in .git/config and exposes it in process arguments. Use credential helpers or other non-URL-based auth to avoid leaking the 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/webclient-jackson3/git_push.sh, line 48:

<comment>GIT_TOKEN is embedded directly in the remote URL, which persists the token in plaintext in .git/config and exposes it in process arguments. Use credential helpers or other non-URL-based auth to avoid leaking the token.</comment>

<file context>
@@ -0,0 +1,57 @@
+        echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
+        git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
+    else
+        git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
+    fi
+
</file context>
Fix with Cubic

@@ -131,20 +131,37 @@ ext {
swagger_annotations_version = "2.2.9"
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 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 always adds jackson-databind-nullable 0.2.9, which is built against Jackson 2.x. This will pull com.fasterxml.jackson.databind 2.x alongside tools.jackson 3.x, leading to classpath/API incompatibilities for openApiNullable users. Consider gating openApiNullable for Jackson3 or upgrading to a Jackson3-compatible nullable module when available.

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/build.gradle.mustache, line 196:

<comment>When useJackson3 is enabled, the template still always adds jackson-databind-nullable 0.2.9, which is built against Jackson 2.x. This will pull com.fasterxml.jackson.databind 2.x alongside tools.jackson 3.x, leading to classpath/API incompatibilities for openApiNullable users. Consider gating openApiNullable for Jackson3 or upgrading to a Jackson3-compatible nullable module when available.</comment>

<file context>
@@ -166,17 +183,25 @@ dependencies {
+    {{#useJackson3}}
+    implementation "tools.jackson.core:jackson-core:$jackson_version"
+    implementation "tools.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
+    implementation "tools.jackson.core:jackson-databind:$jackson_databind_version"
+    implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_annotations_version"
+    {{/useJackson3}}
</file context>
Fix with Cubic

<spring-boot-version>3.2.12</spring-boot-version>
{{/useJackson3}}
{{#useJackson3}}
<spring-boot-version>4.0.3</spring-boot-version>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

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

P2: Non-Jakarta mode now picks Spring Boot 4.0.3 when useJackson3 is true, but non-Jakarta templates still generate javax.* imports. Spring Boot 4 is Jakarta-only, so this combination will not compile/run with the generated code and dependency versions.

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>Non-Jakarta mode now picks Spring Boot 4.0.3 when useJackson3 is true, but non-Jakarta templates still generate javax.* imports. Spring Boot 4 is Jakarta-only, so this combination will not compile/run with the generated code and dependency versions.</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>
Fix with Cubic

petstore_auth.setAccessToken("YOUR ACCESS TOKEN");

PetApi apiInstance = new PetApi(defaultClient);
Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

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

P3: The example declares a Set but initializes it with Arrays.asList(), which returns a List. This snippet will not compile as written.

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/docs/PetApi.md, line 264:

<comment>The example declares a Set<String> but initializes it with Arrays.asList(), which returns a List. This snippet will not compile as written.</comment>

<file context>
@@ -0,0 +1,678 @@
+        petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
+
+        PetApi apiInstance = new PetApi(defaultClient);
+        Set<String> tags = Arrays.asList(); // Set<String> | Tags to filter by
+        try {
+            Set<Pet> result = apiInstance.findPetsByTags(tags);
</file context>
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

This is caused by AbstractJavaCodegen#setParameterExampleValue(CodegenParameter) because of this code bloc:

if (example == null) {
    example = "null";
} else if (Boolean.TRUE.equals(p.isArray)) { // <-- An array can be a Set, eg. if "uniqueItems" is true
    if (p.items != null && p.items.defaultValue != null) {
        String innerExample;
        if ("String".equals(p.items.dataType)) {
            innerExample = "\"" + p.items.defaultValue + "\"";
        } else {
            innerExample = p.items.defaultValue;
        }
        example = "Arrays.asList(" + innerExample + ")"; //  <--- But we unconditionally instanciate it to List
    } else {
        example = "Arrays.asList()"; // <--- Here as well
    }
} else if (Boolean.TRUE.equals(p.isMap)) {
    example = "new HashMap()";
}

I'll create another PR for that fix as this is not related to webclient and Jackson3

Copy link
Author

Choose a reason for hiding this comment

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

|useGzipFeature|Send gzip-encoded requests| |false|
|useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|useJackson3|Use Jackson 3 instead of Jackson 2 for JSON processing. Only supported for 'native' and 'webclient' libraries.| |false|
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 6, 2026

Choose a reason for hiding this comment

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

P3: Duplicate useJackson3 entry in the config options table provides conflicting constraints for the same option, which can mislead users and should be consolidated into a single description.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/java-microprofile.md, line 102:

<comment>Duplicate `useJackson3` entry in the config options table provides conflicting constraints for the same option, which can mislead users and should be consolidated into a single description.</comment>

<file context>
@@ -99,6 +99,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
 |useGzipFeature|Send gzip-encoded requests| |false|
 |useJackson3|Set it in order to use jackson 3 dependencies (only allowed when `useSpringBoot4` is set and incompatible with `openApiNullable`).| |false|
 |useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
+|useJackson3|Use Jackson 3 instead of Jackson 2 for JSON processing. Only supported for 'native' and 'webclient' libraries.| |false|
 |useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped. Only jersey2, jersey3, native, okhttp-gson support this option.| |false|
 |useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
</file context>
Fix with Cubic

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@robinmarechal
Copy link
Author

@wing328 this PR is now ready to be re-reviewed.

The integration tests are now OK:

> mvn integration-test -f samples/client/petstore/java/webclient-jackson3/pom.xml
...
[INFO] Results:
[INFO]
[WARNING] Tests run: 230, Failures: 0, Errors: 0, Skipped: 46
[INFO]
[INFO]
[INFO] --- jar:3.4.1:jar (default-jar) @ petstore-webclient-jackson3 ---
[INFO] Building jar: /home/user/dev/github/perso/contrib/openapi-generator/samples/client/petstore/java/webclient-jackson3/target/petstore-webclient-jackson3-1.0.0.jar
[INFO]
[INFO] --- source:3.3.1:jar-no-fork (attach-sources) @ petstore-webclient-jackson3 ---
[INFO] Building jar: /home/user/dev/github/perso/contrib/openapi-generator/samples/client/petstore/java/webclient-jackson3/target/petstore-webclient-jackson3-1.0.0-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------...

@robinmarechal robinmarechal requested a review from wing328 March 6, 2026 16:47
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.

[REQ] Jackson3 support for java libraries

3 participants