Skip to content

Conversation

@antechrestos
Copy link
Contributor

@antechrestos antechrestos commented Jan 30, 2026

Description

This pull request aim to provide jackson 3 support for spring generator. as it is the recommanded way for any springboot 4 project (see #22294 )

add 'useJackson3' option

I added this option only at the spring generator level, so as not to make it visible for all java generators (as I caught sight of it when a I generated the documentation).
I use this option so as to import the right import of JsonDeserialize as this import is added by the code and not at template level.

I added tests for SpringCodegen in order to test that the jackson 3 import is well added.

add support for RestClient in spring-http-interfaces

The client for spring http interface should use RestClient instead of WebClient in non reactive mode; the WebClient is the reactive implementation of spring clients. As RestClient was added in spring 6.1 / spring boot 3.2, I updated the pom-sb3 dependencies to 3.2.0. Also updated spring cloud to 2023.0.0 for compability with spring boot 3.2 (see compatibility matrix)

add 'useSpringBoot4' option

I willingly introduced this option in order to limitate, for spring generator, the use of jackson 3 only when using a spring boot 4 project.

PR checklist

  • built locally
  • re generated samples
  • regenerated documentation (java camel server inherits from spring
  • test on a personnal project in spring boot 4

Summary by cubic

Adds Jackson 3 support to the Spring generator with new useJackson3 and useSpringBoot4 options, and switches non‑reactive Spring HTTP interface clients to RestClient. Also adds Spring Boot 4 POM templates and updates docs, tests, and samples.

  • New Features

    • New options: useJackson3 to use tools.jackson and useSpringBoot4 to target Spring Boot 4 (enables Jakarta, SB4 POMs).
    • Template toggles for Jackson 2/3 imports (models, YAML/XML, date format, app config).
    • Added SB4 POMs for spring-boot, spring-cloud, and spring-http-interface; bumped SB3 templates to Spring Boot 3.2.0 and Spring Cloud 2023.0.0.
    • Non‑reactive spring-http-interface now uses RestClient + RestClientAdapter; reactive stays on WebClient.
    • Tests for correct Jackson import handling.
  • Migration

    • To use Jackson 3, set useSpringBoot4=true and useJackson3=true; SB4 POMs are used automatically.
    • Choose either useSpringBoot3 or useSpringBoot4 (not both). useJackson3 is only supported with Spring Boot 4.
    • For non‑reactive spring-http-interface clients, provide a RestClient bean and remove WebClient usage; no change for reactive.

Written for commit 07a641f. Summary will update on new commits.

Copy link

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

15 issues found across 87 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.


<file name="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/README.md">

<violation number="1" location="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/README.md:17">
P2: README example passes a WebClient to HttpInterfacesAbstractConfigurator, but the generated configurator expects a RestClient, so the example will not compile.</violation>
</file>

<file name="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/src/main/java/org/openapitools/api/FakeApi.java">

<violation number="1" location="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/src/main/java/org/openapitools/api/FakeApi.java:213">
P2: MultipartFile parameter is declared with @RequestPart, but the request content type is set to application/x-www-form-urlencoded. File uploads in Spring use multipart/form-data, so this mismatch prevents sending the binary part correctly and can lead to 415/empty file data.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom-sb3.mustache:134">
P2: Jackson 3 dependencies are added without a managed version; when useJackson3 is enabled the generated POM lacks a version or BOM for tools.jackson.*, which will cause Maven build failures.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/httpInterfacesConfiguration.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/httpInterfacesConfiguration.mustache:41">
P2: Non-reactive template now requires RestClient (Spring 6.1+), breaking generated code for Spring Boot 3.0/3.1 users without a fallback or version guard.</violation>
</file>

<file name="CONTRIBUTING.md">

<violation number="1" location="CONTRIBUTING.md:15">
P3: Introduced typo in contribution guideline text (“staonrt a discussi”), which should remain “start a discussion.”</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom4.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom4.mustache:98">
P2: `jackson-databind-nullable` is a Jackson 2 module (`com.fasterxml.jackson`) but is always added even when `useJackson3` is enabled, which uses `tools.jackson` artifacts. This mixes incompatible Jackson versions and prevents registering the nullable module with a Jackson 3 `ObjectMapper`.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-http-interface/pom.mustache:58">
P2: The template enables servlet (`spring-boot-starter-web`) when `reactive=false`, but generated code uses `RestClient`, which was introduced in Spring Framework 6.1 (Boot 3.2+). The default parent remains Spring Boot 3.1.3 (Spring 6.0), so non-reactive generated projects will fail to compile due to missing `RestClient`.</violation>
</file>

<file name="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/src/main/java/org/openapitools/api/StoreApi.java">

<violation number="1" location="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/src/main/java/org/openapitools/api/StoreApi.java:39">
P2: `orderId` uses `String` for DELETE but `Long` for GET on the same `{order_id}` path variable, creating an inconsistent API contract for the same endpoint and conflicting with the Javadoc’s integer ID expectation.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb4.mustache:234">
P2: jackson-databind-nullable 0.2.8 is a Jackson 2 module but is always added even in useJackson3 mode, leading to Jackson 2/3 API incompatibility when registering JsonNullableModule.</violation>
</file>

<file name="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/pom.xml">

<violation number="1" location="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/pom.xml:63">
P1: Missing version for tools.jackson.datatype:jackson-datatype-jsr310; without dependencyManagement this will fail Maven resolution.</violation>

<violation number="2" location="samples/client/petstore/spring-http-interface-noResponseEntity-jackson-3/pom.xml:67">
P2: jackson-databind-nullable 0.2.8 is a Jackson 2 module (com.fasterxml.jackson.*) and will not integrate with Jackson 3 (tools.jackson.*) ObjectMapper used by this jackson-3 sample, causing incompatible dependencies.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom-sb3.mustache:184">
P2: Jackson 3 (`tools.jackson.*`) dependencies are added without versions; Spring Boot 3.1.3 only manages `com.fasterxml.jackson.*`, so `useJackson3` builds will fail to resolve these artifacts unless versions/BOM are added.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache:198">
P3: Unreachable mustache block: this dependency is wrapped in {{^useJackson3}}, so the inner {{#useJackson3}} groupId section can never render. This dead code is confusing and likely a logic oversight.</violation>

<violation number="2" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache:199">
P2: Jackson 3 dependencies are added without versions, but Spring Boot 2.7.x parent does not manage tools.jackson.* artifacts. Projects generated with useJackson3 will fail Maven resolution with missing version errors.</violation>

<violation number="3" location="modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache:288">
P2: When `useJackson3` is enabled, the template switches core Jackson dependencies to `tools.jackson.*` but still includes `jackson-databind-nullable` 0.2.8 (a Jackson 2 `com.fasterxml.jackson` module). This creates an incompatible dependency mix and will fail when trying to register the JsonNullable module with a Jackson 3 ObjectMapper.</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
  • 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.

@Picazsoo
Copy link
Contributor

Picazsoo commented Jan 30, 2026

I wonder what use the HttpInterfacesAbstractConfigurator has in practice. I would expect majority of the developers to write their own configuration class such as:

@Configuration
class ApiClientConfig {

    @Bean
    PetApi petApi(WebClient webClient) {
        return HttpServiceProxyFactory
            .builder(WebClientAdapter.forClient(webClient))
            .build()
            .createClient(PetApi.class);
    }
}

I mean - the point of the declarative interface is that it should be client-agnostic. So one can grab it and instantiate their own client with it regardless whether they use WebClient, RestClient or RestTemplate...

In my opinion it just makes maintenance of this generator much more costly than it needs to be for a very little benefit.

And it is not flexible enough. Often one wants to use a different WebClient/RestClient per interface. And this generated one does not seem to offer that.

@antechrestos antechrestos force-pushed the features/add-suppport-for-useJackson3-option-for-spring-generator branch 2 times, most recently from 616c731 to d76e18d Compare January 30, 2026 20:55
* add 'useJackson3' option
* add 'useSpringBoot4' option
* add support for RestClient in spring-http-interfaces

See OpenAPITools#22294
@antechrestos antechrestos force-pushed the features/add-suppport-for-useJackson3-option-for-spring-generator branch from d76e18d to 07a641f Compare January 30, 2026 20:56
@antechrestos
Copy link
Contributor Author

antechrestos commented Jan 30, 2026

@Picazsoo I juste adapted the existing code and did not want to bring toomuch change in this, quite already, big change 😅

In my case I only generates interface and model, and generates client in my code with interceptors, url and so on...

@Picazsoo
Copy link
Contributor

Yes, I understand you are simply working with the current state and bringing it up to date. No problem with that (-: !

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