Skip to content

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

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions