Skip to content

Comments

feature(jackson3) add jackson3 support for Java Client generator - Restclient#23023

Open
alex-nt wants to merge 12 commits intoOpenAPITools:masterfrom
alex-nt:feature/java.restclient.spring7
Open

feature(jackson3) add jackson3 support for Java Client generator - Restclient#23023
alex-nt wants to merge 12 commits intoOpenAPITools:masterfrom
alex-nt:feature/java.restclient.spring7

Conversation

@alex-nt
Copy link
Contributor

@alex-nt alex-nt commented Feb 21, 2026

Add option to generate Restclient using latest spring 7.

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)
    • fixes #22985
  • 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 Spring Boot 4 / Spring Framework 7 support to the Java RestClient generator with an optional Jackson 3 path. Updates templates, converters, and samples on a Java 17 baseline.

  • New Features

    • New options: useSpringBoot4 and useJackson3 (requires useSpringBoot4; incompatible with openApiNullable).
    • Jackson 2/3 switching: dynamic packages (com.fasterxml.jackson vs tools.jackson), ObjectMapper vs JsonMapper, Spring JacksonJson/Xml HttpMessageConverters for Jackson 3, and RFC3339DateFormat import.
    • Models: removed @JsonIgnore on no-arg constructors (reverted previous Jackson 3-only addition).
    • Docs updated with useJackson3; new generator configs for Spring Boot 4 + Jackson 2 and Jackson 3.
    • Java 17 baseline with plugin bumps; new Petstore sample (Spring Boot 4 + Jackson 2) and CI.
  • Migration

    • Set useSpringBoot4=true (and useJackson3=true to switch to Jackson 3); build with Java 17+.
    • For Jackson 3, set openApiNullable=false and use JacksonJsonHttpMessageConverter (and JacksonXmlHttpMessageConverter for XML).

Written for commit 1b3aefc. 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.

4 issues found across 228 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-spring-7/docs/PetApi.md">

<violation number="1" location="samples/client/petstore/java/restclient-spring-7/docs/PetApi.md:264">
P2: The example initializes a Set with Arrays.asList(), which returns a List and causes a compile-time type mismatch in the documentation sample.</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:188">
P2: Spring7 default JsonMapper omits JsonNullableModule registration, so generated clients using openApiNullable will not correctly serialize/deserialize JsonNullable fields.</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/restclient-spring-7/docs/FakeApi.md:1007">
P2: The example initializes a List<EnumClass> with `Arrays.asList(-efg)`, which is invalid Java syntax and will not compile. The documentation should use a valid EnumClass constant or factory method for the enum value.</violation>
</file>

<file name="samples/client/petstore/java/restclient-spring-7/.travis.yml">

<violation number="1" location="samples/client/petstore/java/restclient-spring-7/.travis.yml:8">
P2: Travis CI tests only JDK 8–12, but this sample requires Java 17 in build.gradle, so CI will fail to compile or test. Update the matrix to include Java 17+ and drop unsupported versions.</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.

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 Feb 21, 2026

Choose a reason for hiding this comment

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

P2: The example initializes a Set with Arrays.asList(), which returns a List and causes a compile-time type mismatch in the documentation sample.

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

<comment>The example initializes a Set with Arrays.asList(), which returns a List and causes a compile-time type mismatch in the documentation sample.</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

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

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

Choose a reason for hiding this comment

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

P2: Spring7 default JsonMapper omits JsonNullableModule registration, so generated clients using openApiNullable will not correctly serialize/deserialize JsonNullable fields.

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 188:

<comment>Spring7 default JsonMapper omits JsonNullableModule registration, so generated clients using openApiNullable will not correctly serialize/deserialize JsonNullable fields.</comment>

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

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 21, 2026

Choose a reason for hiding this comment

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

P2: The example initializes a List with Arrays.asList(-efg), which is invalid Java syntax and will not compile. The documentation should use a valid EnumClass constant or factory method for the enum value.

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-spring-7/docs/FakeApi.md, line 1007:

<comment>The example initializes a List<EnumClass> with `Arrays.asList(-efg)`, which is invalid Java syntax and will not compile. The documentation should use a valid EnumClass constant or factory method for the enum value.</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

#
language: java
jdk:
- openjdk12
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: Travis CI tests only JDK 8–12, but this sample requires Java 17 in build.gradle, so CI will fail to compile or test. Update the matrix to include Java 17+ and drop unsupported versions.

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-spring-7/.travis.yml, line 8:

<comment>Travis CI tests only JDK 8–12, but this sample requires Java 17 in build.gradle, so CI will fail to compile or test. Update the matrix to include Java 17+ and drop unsupported versions.</comment>

<file context>
@@ -0,0 +1,22 @@
+#
+language: java
+jdk:
+  - openjdk12
+  - openjdk11
+  - openjdk10
</file context>
Fix with Cubic

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to standardize the name of the options with the Spring generator:

<useJackson3>true</useJackson3>
<useSpringBoot4>true</useSpringBoot4> >

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I initially misread the spring docs 🙈.

@jpfinne
Copy link
Contributor

jpfinne commented Feb 21, 2026

Jackson3 also tries to deserialize using constructors. It might give regressions. See #22978

it can be fixed by adding @JsonIgnore to the generated required and all arguments constructors.
I would add it for jackson2 and jackson3, so that the generated Dtos are backward and forward compatible

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.

4 issues found across 433 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 example code uses `Arrays.asList(-efg)`, which is not a valid Java enum literal or identifier, so the sample will not compile.</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/docs/PetApi.md:264">
P2: The example initializes a Set with Arrays.asList(), which returns a List and won’t compile. The docs should construct a Set (e.g., new HashSet<>(Arrays.asList(...))) or use Set.of().</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: build.sbt is an empty TODO placeholder, leaving the SBT build for this sample non-functional.</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:187">
P2: Jackson 3 default mapper doesn’t register JsonNullableModule when openApiNullable is enabled, so JsonNullable fields won’t serialize/deserialize correctly in the default RestClient setup.</violation>
</file>

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 21, 2026

Choose a reason for hiding this comment

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

P2: The example code uses Arrays.asList(-efg), which is not a valid Java enum literal or identifier, so the sample will not compile.

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 example code uses `Arrays.asList(-efg)`, which is not a valid Java enum literal or identifier, so the sample will not compile.</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

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 Feb 21, 2026

Choose a reason for hiding this comment

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

P2: The example initializes a Set with Arrays.asList(), which returns a List and won’t compile. The docs should construct a Set (e.g., new HashSet<>(Arrays.asList(...))) or use Set.of().

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

<comment>The example initializes a Set with Arrays.asList(), which returns a List and won’t compile. The docs should construct a Set (e.g., new HashSet<>(Arrays.asList(...))) or use Set.of().</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

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

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

Choose a reason for hiding this comment

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

P2: build.sbt is an empty TODO placeholder, leaving the SBT build for this sample non-functional.

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>build.sbt is an empty TODO placeholder, leaving the SBT build for this sample non-functional.</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 21, 2026

Choose a reason for hiding this comment

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

P2: Jackson 3 default mapper doesn’t register JsonNullableModule when openApiNullable is enabled, so JsonNullable fields won’t serialize/deserialize correctly in the default RestClient setup.

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 187:

<comment>Jackson 3 default mapper doesn’t register JsonNullableModule when openApiNullable is enabled, so JsonNullable fields won’t serialize/deserialize correctly in the default RestClient setup.</comment>

<file context>
@@ -159,7 +182,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

@alex-nt
Copy link
Contributor Author

alex-nt commented Feb 21, 2026

Jackson3 also tries to deserialize using constructors. It might give regressions. See #22978

it can be fixed by adding @JsonIgnore to the generated required and all arguments constructors. I would add it for jackson2 and jackson3, so that the generated Dtos are backward and forward compatible

@jpfinne, this will work for vendorExtensions.x-java-all-args-constructor but how should it behave for vendorExtensions.x-has-readonly-properties?

@alex-nt alex-nt changed the title Spring 7 option for Java Client - Restclient feature(jackson3) add jackson3 support for Java Client generator - Restclient Feb 21, 2026
@jpfinne
Copy link
Contributor

jpfinne commented Feb 21, 2026

Jackson3 also tries to deserialize using constructors. It might give regressions. See #22978
it can be fixed by adding @JsonIgnore to the generated required and all arguments constructors. I would add it for jackson2 and jackson3, so that the generated Dtos are backward and forward compatible

@jpfinne, this will work for vendorExtensions.x-java-all-args-constructor but how should it behave for vendorExtensions.x-has-readonly-properties?

Good question. Jackson3 tries to find a constructor for the deseralization. An all args constructor is used for sure. I would add @JsonIgnore to all non arg constructors. It doesn't harm? The setters will be used as for jackson2? To be tested.

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 650 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/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/model/InlineObject.java">

<violation number="1" location="samples/client/others/java/restclient-enum-in-multipart/src/main/java/org/openapitools/client/model/InlineObject.java:41">
P2: @JsonIgnore on the only no‑args constructor makes Jackson ignore the sole creator, which can break deserialization for this model.</violation>
</file>

<file name="samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/Query.java">

<violation number="1" location="samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/Query.java:84">
P2: @JsonIgnore on the only no-args constructor prevents Jackson from treating it as a creator, leaving no usable constructor for deserialization of Query.</violation>
</file>

<file name="samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DataQuery.java">

<violation number="1" location="samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/model/DataQuery.java:54">
P2: @JsonIgnore on the only no-arg constructor prevents Jackson from using it as a creator, leaving no constructor for deserialization and likely breaking JSON parsing for DataQuery.</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/.travis.yml:8">
P2: Travis CI matrix omits JDK 17 even though the sample enforces Java 17 source/target compatibility, so CI builds on the listed JDKs will fail or not test the required baseline.</violation>
</file>

<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 example uses `Arrays.asList(-efg)` which is not valid Java syntax for an enum value; it should reference the EnumClass constant (e.g., EnumClass._EFG).</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/restclient-springBoot4-jackson2/build.gradle:35">
P2: Android build uses AGP 1.5 but sets Java 17 source/target; AGP 1.5 predates Java 8 support and won’t handle Java 17, so Android builds will fail when target=android is used.</violation>
</file>

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

#
language: java
jdk:
- openjdk12
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: Travis CI matrix omits JDK 17 even though the sample enforces Java 17 source/target compatibility, so CI builds on the listed JDKs will fail or not test the required baseline.

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/.travis.yml, line 8:

<comment>Travis CI matrix omits JDK 17 even though the sample enforces Java 17 source/target compatibility, so CI builds on the listed JDKs will fail or not test the required baseline.</comment>

<file context>
@@ -0,0 +1,22 @@
+#
+language: java
+jdk:
+  - openjdk12
+  - openjdk11
+  - openjdk10
</file context>
Fix with Cubic

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 example uses Arrays.asList(-efg) which is not valid Java syntax for an enum value; it should reference the EnumClass constant (e.g., EnumClass._EFG).

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 example uses `Arrays.asList(-efg)` which is not valid Java syntax for an enum value; it should reference the EnumClass constant (e.g., EnumClass._EFG).</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

targetSdkVersion 22
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
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: Android build uses AGP 1.5 but sets Java 17 source/target; AGP 1.5 predates Java 8 support and won’t handle Java 17, so Android builds will fail when target=android is used.

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.gradle, line 35:

<comment>Android build uses AGP 1.5 but sets Java 17 source/target; AGP 1.5 predates Java 8 support and won’t handle Java 17, so Android builds will fail when target=android is used.</comment>

<file context>
@@ -0,0 +1,136 @@
+            targetSdkVersion 22
+        }
+        compileOptions {
+            sourceCompatibility JavaVersion.VERSION_17
+            targetCompatibility JavaVersion.VERSION_17
+        }
</file context>
Fix with Cubic

@jpfinne
Copy link
Contributor

jpfinne commented Feb 22, 2026

Jackson3 also tries to deserialize using constructors. It might give regressions. See #22978
it can be fixed by adding @JsonIgnore to the generated required and all arguments constructors. I would add it for jackson2 and jackson3, so that the generated Dtos are backward and forward compatible

@jpfinne, this will work for vendorExtensions.x-java-all-args-constructor but how should it behave for vendorExtensions.x-has-readonly-properties?

Good question. Jackson3 tries to find a constructor for the deseralization. An all args constructor is used for sure. I would add @JsonIgnore to all non arg constructors. It doesn't harm? The setters will be used as for jackson2? To be tested.

@alex-nt Forget about @JsonIgnore. I missed the fact that the java generator adds @JsonProperty to the arguments in the generated constructors. It even adds @jsonCreator to enforce the use of the constructor.
This is good as there is not setter when readonly constructors exist.

So the java generator is better that the spring generator !
Sorry for the wrong information

@alex-nt
Copy link
Contributor Author

alex-nt commented Feb 22, 2026

@jpfinne done, I reverted to what was there before. I think now it should be ok?

@jpfinne
Copy link
Contributor

jpfinne commented Feb 22, 2026

@alex-nt

@jpfinne done, I reverted to what was there before. I think now it should be ok?

My third thought:
Keep readonly constructor as is.
Put @JsonIgnore on all arg constructor.

For example, the restclient generation with all arg constructors gives

public class ArrayTest {
  public static final String JSON_PROPERTY_ARRAY_OF_STRING = "array_of_string";
  @jakarta.annotation.Nullable
  private List<String> arrayOfString = new ArrayList<>();

  public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER = "array_array_of_integer";
  @jakarta.annotation.Nullable
  private List<List<Long>> arrayArrayOfInteger = new ArrayList<>();

  public static final String JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL = "array_array_of_model";
  @jakarta.annotation.Nullable
  private List<List<ReadOnlyFirst>> arrayArrayOfModel = new ArrayList<>();

  public ArrayTest() {
  }

  /**
   * Constructor with all args parameters
   */
  public ArrayTest(@JsonProperty(JSON_PROPERTY_ARRAY_OF_STRING) List<String> arrayOfString, @JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_INTEGER) List<List<Long>> arrayArrayOfInteger, @JsonProperty(JSON_PROPERTY_ARRAY_ARRAY_OF_MODEL) List<List<ReadOnlyFirst>> arrayArrayOfModel) {
    this.arrayOfString = arrayOfString;
    this.arrayArrayOfInteger = arrayArrayOfInteger;
    this.arrayArrayOfModel = arrayArrayOfModel;
  } 

The all arg constructor is used by jackson3 to deserialize. Jackson2 uses the setters.
So deserializing { } gives 3 empty lists with jackson2 and 3 null lists with jackson3

@alex-nt
Copy link
Contributor Author

alex-nt commented Feb 23, 2026

@jpfinne I checked the generated files and cannot see where it is generated with default value. You mention the following:

  public static final String JSON_PROPERTY_ARRAY_OF_STRING = "array_of_string";
  @jakarta.annotation.Nullable
  private List<String> arrayOfString = new ArrayList<>();

But I see it generated as:

  public static final String JSON_PROPERTY_ARRAY_OF_STRING = "array_of_string";
  @jakarta.annotation.Nullable
  private List<String> arrayOfString;

What else do I need to enable in order to get also default (non-null) values? By adding generateConstructorWithAllArgs I can't make it reproduce.

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