Skip to content

[BUG][Java][RestClient][jackson3] restclient.messageConverters unset for ApiClient with default construction #23354

@chumbalum

Description

@chumbalum

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
  • when constructing an ApiClient with the default constructor, the internal generated RestClient will not have any messageConverters set, resulting in errors like
Could not extract response: no suitable HttpMessageConverter found for response type [class ag.xyz.model.SomethingDto] and content type [application/json]
openapi-generator version
  • openapi-generator-maven-plugin 7.21.0
  • spring framework 7.0.6

additional params used

<useSpringBoot4>true</useSpringBoot4>
<useJackson3>true</useJackson3>
<library>restclient</library>
<openApiNullable>false</openApiNullable>
<useJakartaEe>true</useJakartaEe>
<generateBuilders>true</generateBuilders>
<useSingleRequestParameter>static</useSingleRequestParameter>
<useAbstractionForFiles>true</useAbstractionForFiles>

Steps to reproduce
  • create ApiClient with default constructor
  • apiClient.restClient.messageConverters will be empty
this.apiClient = new ApiClient();
  • create ApiClient with construction like in mustache template
  • apiClient.restClient.messageConverters will be empty
this.apiClient = new ApiClient(RestClient.builder()
		.configureMessageConverters(c -> c
				.withJsonConverter(new JacksonJsonHttpMessageConverter())
		)
		.build()
);
  • create ApiClient with construction like in mustache template, but use registerDefaults
  • apiClient.restClient.messageConverters will have entries (5), including the JacksonJsonHttpMessageConverter
this.apiClient = new ApiClient(RestClient.builder()
		.configureMessageConverters(c -> c
				.registerDefaults()
				.withJsonConverter(new JacksonJsonHttpMessageConverter())
		)
		.build()
);
Related issues/PRs
Suggest a fix
  • adding registerDefaults() beforehand withJsonConverter(...) will lead to existing messageConverters, nevertheless I'm not too deep into it, to see the full consequences

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