Skip to content

[BUG][SPRING] Deprecated MappingJackson2HttpMessageConverter for RestClient generator #22985

Closed

Description

@faltfe

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

After upgrading the openapi-generator-maven-plugin to 7.20.0 I tried the new options useJackson3 and useSpringBoot4 (see #22854)
I still get the messages

  • [removal] MappingJackson2HttpMessageConverter in org.springframework.http.converter.json is deprecated and marked for removal
  • [removal] messageConverters(Consumer<List<HttpMessageConverter<?>>>) in Builder is deprecated and marked for removal
openapi-generator version

7.20.0

OpenAPI declaration file content or url
Generation Details
<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>7.20.0</version>
    <executions>
        <execution>
            <id>generate-client</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <inputSpec>
                    ${project.build.directory}/generated-resources/src/main/resources/api/openapi.yaml
                </inputSpec>
                <generatorName>java</generatorName>
                <configOptions>
                    <library>restclient</library>
                    <useJakartaEe>true</useJakartaEe>
                    <dateLibrary>java8</dateLibrary>
                    <useJackson3>true</useJackson3>
                    <useSpringBoot4>true</useSpringBoot4>
                    <implicitHeaders>true</implicitHeaders>
                    <invokerPackage>faltfe.service</invokerPackage>
                    <configPackage>faltfe.config</configPackage>
                    <apiPackage>faltfe.api</apiPackage>
                    <modelPackage>faltfe.model</modelPackage>
                </configOptions>
                <generateModelTests>false</generateModelTests>
                <generateApiTests>false</generateApiTests>
            </configuration>
        </execution>
    </executions>
</plugin>

With the java configuration

@Configuration
@RequiredArgsConstructor
public class IamsConfiguration {

    private final ArmsProperties armProperties;

    @Bean
    public ApiClient apiClient() {
        var apiClient = new CustomApiClient().apiClient();
        apiClient.setBasePath("http://localhost:8000");
        return apiClient;
    }

    @Bean
    public UserApi userApi(ApiClient apiClient) {
        return new UserApi(apiClient);
    }

    private class CustomApiClient extends ApiClient {

        ApiClient apiClient() {
            var restClient = this.restClient.mutate().requestInterceptor((request, body, execution) -> {
                request.getHeaders().add("tenant", "Foobar");
                return execution.execute(request, body);
            });
            return new ApiClient(restClient.build());
        }
    }
}
Steps to reproduce

Generate any YAML input spec the see the log messages from Maven. There are at least two warnings about the deprections.

Related issues/PRs

#22854

Suggest a fix

I would expect that there is no warning when using Jackson3.

Activity

  1. faltfe commented on Feb 16, 2026

    @faltfe
    ContributorAuthor

    Btw., the documentation appears to be unchanged since version 7.20.0
    https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/java.md Jackson 3 is not mentioned there

  2. Picazsoo commented on Feb 17, 2026

    @Picazsoo
    Contributor

    I see in your config: <generatorName>java</generatorName>

    The issue title mentions spring and yet you are using java generator in your config.

    I am quite certain that the functionality has been implemented only in the java-spring codegen (commonly refered to in the issues as java-spring to differentiate it from kotlin-spring). And I can see jackson3 mentioned in the docs: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md

    So if you want to use it, you should do: <generatorName>spring</generatorName>

  3. faltfe commented on Feb 17, 2026

    @faltfe
    ContributorAuthor

    Thanks for your response. As I want to generate a client not a server from the API spec I currently use the <library>restclient</library> which generates a Spring client. Therefore, I guess, it is not a bug it is a feature request to support Spring Boot 4 and Jackson 3 with the RestClient.

  4. Picazsoo commented on Feb 17, 2026

    @Picazsoo
    Contributor

    Have you considered going the spring http declarative interface route? (available in spring generator as spring-http-interface library). If it is suitable for your needs, you can use it easily with RestClient.

    And regarding the support in java generator - I presume it will come in due time. Someone will have to implement it once they feel the need for it. You could be that someone (-:

    Just to make it clear - I am not a maintainer of this project. We just use it extensively at our company and I am compelled to give back at least a little.

  5. faltfe commented on Feb 19, 2026

    @faltfe
    ContributorAuthor

    I try to change the generator to spring with <library>spring-http-interface</library>. Unfortunately, it fails with <useSpringBoot4>true</useSpringBoot4> because of missing imports in the generated Api classes.

        @HttpExchange(
            method = "GET",
            value = "/groups/contains",
            accept = { "application/json", "application/problem+json" }
        )
        ResponseEntity<List<UserGroupMembership>> checkUserMembership(
            @Parameter(name = "userIds", description = "Hello world", required = true, in = ParameterIn.QUERY) @RequestParam(value = "userIds", required = true) List<String> userIds,
            @Parameter(name = "groupFilter", description = "", in = ParameterIn.QUERY) @Nullable UserGroupFilter groupFilter
        );

    Imports are missing for

    • @Parameter
    • @ParameterIn

    I also tested <annotationLibrary>swagger2</annotationLibrary> and without <useSpringBoot4>true</useSpringBoot4> . The result was always an compilation error caused by missing imports. Manually importing is possible.

    When I use <useSpringBoot3>true</useSpringBoot3> the generation fails as well with the error:

    java.lang.RuntimeException: Could not generate supporting file 'SupportingFile[templateFile='pom-sb3.mustache', folder='', destinationFilename='pom.xml', canOverwrite=true]'
    at org.openapitools.codegen.DefaultGenerator.generateSupportingFiles (DefaultGenerator.java:1104)
    at org.openapitools.codegen.DefaultGenerator.generate (DefaultGenerator.java:1301)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:1005)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:565)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
    Caused by: org.openapitools.codegen.templating.TemplateNotFoundException: pom-sb3.mustache
    at org.openapitools.codegen.TemplateManager.getFullTemplateFile (TemplateManager.java:60)
    at org.openapitools.codegen.TemplateManager.getFullTemplateContents (TemplateManager.java:78)
    at org.openapitools.codegen.templating.MustacheEngineAdapter.compileTemplate (MustacheEngineAdapter.java:68)
    at org.openapitools.codegen.TemplateManager.write (TemplateManager.java:167)
    at org.openapitools.codegen.DefaultGenerator.processTemplateToFile (DefaultGenerator.java:1450)
    at org.openapitools.codegen.DefaultGenerator.processTemplateToFile (DefaultGenerator.java:1430)
    at org.openapitools.codegen.DefaultGenerator.generateSupportingFiles (DefaultGenerator.java:1096)
    at org.openapitools.codegen.DefaultGenerator.generate (DefaultGenerator.java:1301)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:1005)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:565)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)

  6. Picazsoo commented on Feb 19, 2026

    @Picazsoo
    Contributor

    Ok, let me check this. I remember this being tricky.

  7. Picazsoo commented on Feb 19, 2026

    @Picazsoo
    Contributor

    can you try to set documentationProvider to none?

  8. alex-nt commented on Feb 21, 2026

    @alex-nt
    Contributor

    Maybe this will help? #23023

  9. faltfe commented on Feb 23, 2026

    @faltfe
    ContributorAuthor

    can you try to set documentationProvider to none?

    With documentProvider set to none the code compiles. The only problem is now that the generates methods return ResponseEntity<Object> instead of Object like before with RestClient. But I can refactor this.

    Maybe this will help? #23023

    That looks promising. I'm looking forward to test it in the next release.

  10. Picazsoo commented on Feb 23, 2026

    @Picazsoo
    Contributor

    try setting "useResponseEntity" to "false" in additional properties

  11. faltfe commented on Feb 25, 2026

    @faltfe
    ContributorAuthor

    try setting "useResponseEntity" to "false" in additional properties

    Using useResponseEntity as configOption is working

    <generatorName>spring</generatorName>
    <configOptions>
        <library>spring-http-interface</library>
        <useJackson3>true</useJackson3>
        <useSpringBoot4>true</useSpringBoot4>
        <openApiNullable>false</openApiNullable>
        <documentationProvider>none</documentationProvider>
        <useResponseEntity>false</useResponseEntity>
        <implicitHeaders>true</implicitHeaders>
    </configOptions>

    Maven builds the project successfully but I have an issue with exploded parameters.

    I have OpenAPI definition like

    get:
          tags:
            - user
          summary: List all users
          description: Returns a list of all known users.
          operationId: getAllUsers
          parameters:
            - $ref: './schemas/schemas.yaml#/components/parameters/UserFilterParam'
            - $ref: './schemas/schemas.yaml#/components/parameters/UserGroupFilterParam'
            - $ref: './schemas/schemas.yaml#/components/parameters/UserPageParam'
            - $ref: './schemas/schemas.yaml#/components/parameters/UserSortParam'

    They are all defined like

        UserGroupFilterParam:
          name: groupFilter
          in: query
          style: form
          explode: true
          required: false
          schema:
            $ref: "#/components/schemas/UserGroupFilter"

    The generated code

        @ResponseStatus(HttpStatus.OK)
        @HttpExchange(
            method = "GET",
            value = "/users",
            accept = { "application/json", "application/problem+json" }
        )
        List<User> getAllUsers(
             @Nullable UserFilter userFilter,
             @Nullable UserGroupFilter groupFilter,
             @Nullable UserPage userPage,
             @Nullable UserSort userSort
        );

    When I run a request again the generated API client I get an error because the object is not exloded like before with the RestClient. As I'm new to HTTP interfaces with Spring Boot, I'm not sure yet, if it is a configuration issue or if there is something missing in the generated files. The exception is that there is no resolver for parameter [0].

  12. Picazsoo commented on Mar 5, 2026

    @Picazsoo
    Contributor

    Hi @faltfe , since the fix is merged in #23023, I guess you can close this? Or are you waiting to really test it before closing the issue? Makes sense - just asking.

  13. faltfe commented on Mar 17, 2026

    @faltfe
    ContributorAuthor

    I would like to wait for a release to test this. Otherwise, you can close it, when this is your workflow in this project. I will open a new issue when the problem is not solved in the next release.

  14. Picazsoo commented on Mar 17, 2026

    @Picazsoo
    Contributor

    Makes sense to keep it open. The release is just days from now anyways.

  15. wing328 commented on Mar 17, 2026

    @wing328
    Member

    I would like to wait for a release to test this.

    please help test the latest master if you've time: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-to-test-with-the-latest-master-of-openapi-generator

  16. faltfe commented on Mar 25, 2026

    @faltfe
    ContributorAuthor

    With the latest release 7.21.0 <useSpringBoot4>true</useSpringBoot4> with restclient is working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions