Skip to content

[java][resttemplate] Add support for Jackson 3 and Spring Boot 4 in Java resttemplate#23144

Open
jorgerod wants to merge 10 commits intoOpenAPITools:masterfrom
InditexTech:feature/GH-22294-rest-template-support-jackson-3
Open

[java][resttemplate] Add support for Jackson 3 and Spring Boot 4 in Java resttemplate#23144
jorgerod wants to merge 10 commits intoOpenAPITools:masterfrom
InditexTech:feature/GH-22294-rest-template-support-jackson-3

Conversation

@jorgerod
Copy link
Contributor

@jorgerod jorgerod commented Mar 5, 2026

Add option to generate Resttemplate 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)
  • 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
@sreeshas
@jfiala
@lukoyanov
@cbornet
@jeff9finger
@karismann
@Zomzog
@lwlee2608
@martin-mfg


Summary by cubic

Adds optional RestTemplate generation for Spring Framework 7 (Spring Boot 4) with Jackson 3. Opt-in only; existing defaults stay the same.

  • New Features

    • New flags: useSpringBoot4 and useJackson3 (requires useSpringBoot4; incompatible with openApiNullable).
    • Jackson groupId switches via jacksonPackage; Gradle/POM use jackson_version and align jackson-databind to jackson_version; JSON/XML imports updated.
    • Spring Boot 4 sets spring-web 7.0.5, bean-validation 3.1.1, and Java 17; Jakarta uses spring-web 6.2.x; legacy remains 5.3.x. Jackson 3 drops jackson-datatype-jsr310.
    • Added sample configs and generated samples for resttemplate-springBoot4-jackson2 and -jackson3; CI builds these on JDK 17/21.
    • Maintenance: removed unused test files; added libs.versions.toml and updated sample FILES lists.
  • Migration

    • Opt in with -DuseSpringBoot4=true; add -DuseJackson3=true for Jackson 3.
    • Build with JDK 17 when useSpringBoot4=true; with useJackson3=true also set -DopenApiNullable=false.
    • No changes unless these flags are set.

Written for commit 5bcd5c0. Summary will update on new commits.

@jorgerod jorgerod changed the title feat: add support for Jackson 3 and Spring Boot 4 in Java resttemplate feat: Add support for Jackson 3 and Spring Boot 4 in Java resttemplate Mar 5, 2026
@jorgerod jorgerod changed the title feat: Add support for Jackson 3 and Spring Boot 4 in Java resttemplate [java][resttemplate] Add support for Jackson 3 and Spring Boot 4 in Java resttemplate Mar 5, 2026
@jorgerod jorgerod marked this pull request as ready for review March 5, 2026 17:13
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 562 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="samples/client/petstore/java/resttemplate-springBoot4-jackson2/docs/EnumArrays.md">

<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson2/docs/EnumArrays.md:10">
P2: Enum property links use fragment IDs that don’t match the actual enum heading anchors, causing broken intra-doc navigation.</violation>
</file>

<file name="samples/client/petstore/java/resttemplate-springBoot4-jackson2/README.md">

<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson2/README.md:18">
P2: README lists an incorrect Java minimum version for the Spring Boot 4 sample, which will mislead users into unsupported JDKs.</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson2/docs/FakeApi.md:1007">
P2: The generated Java example uses `Arrays.asList(-efg)`, which is invalid Java syntax; it should reference a valid enum constant (e.g., `EnumClass._EFG`) or `EnumClass.fromValue("-efg")` so the example compiles.</violation>
</file>

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

<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson2/.travis.yml:8">
P2: Travis CI matrix uses JDK 8–12, but this sample requires Java 17 (build.gradle sets source/target 17), so CI will fail on these runtimes.</violation>
</file>

<file name=".github/workflows/samples-java-client-jdk17.yaml">

<violation number="1" location=".github/workflows/samples-java-client-jdk17.yaml:32">
P1: New Spring Boot 4 RestTemplate samples were added to the build matrix without corresponding workflow path triggers, so PRs/commits touching only those folders can skip this CI workflow.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache:159">
P2: The new useSpringBoot4 properties block omits beanvalidation-version, but the Bean Validation dependency still references ${beanvalidation-version}. If useSpringBoot4 and useBeanValidation are enabled together, Maven fails with an unresolved property. Define beanvalidation-version in the useSpringBoot4 branch to avoid build failures.</violation>
</file>

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

Comment on lines +10 to +11
|**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) | | [optional] |
|**arrayEnum** | [**List&lt;ArrayEnumEnum&gt;**](#List&lt;ArrayEnumEnum&gt;) | | [optional] |
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: Enum property links use fragment IDs that don’t match the actual enum heading anchors, causing broken intra-doc navigation.

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

<comment>Enum property links use fragment IDs that don’t match the actual enum heading anchors, causing broken intra-doc navigation.</comment>

<file context>
@@ -0,0 +1,32 @@
+
+| Name | Type | Description | Notes |
+|------------ | ------------- | ------------- | -------------|
+|**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) |  |  [optional] |
+|**arrayEnum** | [**List&lt;ArrayEnumEnum&gt;**](#List&lt;ArrayEnumEnum&gt;) |  |  [optional] |
+
</file context>
Suggested change
|**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) | | [optional] |
|**arrayEnum** | [**List&lt;ArrayEnumEnum&gt;**](#List&lt;ArrayEnumEnum&gt;) | | [optional] |
|**justSymbol** | [**JustSymbolEnum**](#enum-justsymbolenum) | | [optional] |
|**arrayEnum** | [**List&lt;ArrayEnumEnum&gt;**](#enum-listarrayenumenum) | | [optional] |
Fix with Cubic


Building the API client library requires:

1. Java 1.8+
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: README lists an incorrect Java minimum version for the Spring Boot 4 sample, which will mislead users into unsupported JDKs.

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

<comment>README lists an incorrect Java minimum version for the Spring Boot 4 sample, which will mislead users into unsupported JDKs.</comment>

<file context>
@@ -0,0 +1,278 @@
+
+Building the API client library requires:
+
+1. Java 1.8+
+2. Maven/Gradle
+
</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 Mar 5, 2026

Choose a reason for hiding this comment

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

P2: The generated Java example uses Arrays.asList(-efg), which is invalid Java syntax; it should reference a valid enum constant (e.g., EnumClass._EFG) or EnumClass.fromValue("-efg") so the example compiles.

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

<comment>The generated Java example uses `Arrays.asList(-efg)`, which is invalid Java syntax; it should reference a valid enum constant (e.g., `EnumClass._EFG`) or `EnumClass.fromValue("-efg")` so the example compiles.</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>
Suggested change
List<EnumClass> enumQueryModelArray = Arrays.asList(-efg); // List<EnumClass> |
List<EnumClass> enumQueryModelArray = Arrays.asList(EnumClass._EFG); // List<EnumClass> |
Fix with Cubic

#
language: java
jdk:
- openjdk12
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 5, 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 uses JDK 8–12, but this sample requires Java 17 (build.gradle sets source/target 17), so CI will fail on these runtimes.

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

<comment>Travis CI matrix uses JDK 8–12, but this sample requires Java 17 (build.gradle sets source/target 17), so CI will fail on these runtimes.</comment>

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

@@ -156,10 +156,14 @@
<source>17</source>
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: The new useSpringBoot4 properties block omits beanvalidation-version, but the Bean Validation dependency still references ${beanvalidation-version}. If useSpringBoot4 and useBeanValidation are enabled together, Maven fails with an unresolved property. Define beanvalidation-version in the useSpringBoot4 branch to avoid build failures.

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/resttemplate/pom.mustache, line 159:

<comment>The new useSpringBoot4 properties block omits beanvalidation-version, but the Bean Validation dependency still references ${beanvalidation-version}. If useSpringBoot4 and useBeanValidation are enabled together, Maven fails with an unresolved property. Define beanvalidation-version in the useSpringBoot4 branch to avoid build failures.</comment>

<file context>
@@ -156,10 +156,14 @@
                     <target>17</target>
                 {{/useJakartaEe}}
-                {{^useJakartaEe}}
+                {{#useSpringBoot4}}
+                    <source>17</source>
+                    <target>17</target>
</file context>
Fix with Cubic

@jorgerod jorgerod requested a review from wing328 March 6, 2026 08:47
@wing328
Copy link
Member

wing328 commented Mar 6, 2026

can you please review the build failure when you've time?

@jorgerod
Copy link
Contributor Author

jorgerod commented Mar 6, 2026

can you please review the build failure when you've time?

I have run the tests locally and they are working fine. On GitHub, the error I see is:
/home/runner/work/_temp/291e3712-3492-4639-8a81-c2b055936578.sh: line 1: ./gradlew: Permission denied

@wing328 Can you guide me?

@wing328
Copy link
Member

wing328 commented Mar 6, 2026

what about copying ./gradlew from one of the existing folders for Java resttemplate client to the new folders you just created in this PR?

e.g. https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/java/resttemplate/gradlew

@Mattias-Sehlstedt
Copy link
Contributor

Note that RestTemplate is scheduled to be deprecated. So I would suggest to switch to RestClient if possible.

@jorgerod
Copy link
Contributor Author

jorgerod commented Mar 6, 2026

Note that RestTemplate is scheduled to be deprecated. So I would suggest to switch to RestClient if possible.

True, but in my case migrating to RestClient isn't feasible at this time.

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.

3 participants