fixes(java/restclient) Force usage of custom converter (#20112)

* fixes(java/restclient) Force usage of custom converter

Insert custom converter at the beginning of the 'RestClientBuilder' converter list so as not to use default 'MappingJackson2HttpMessageConverter' 

Close #20111

* update samples

---------

Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
Benjamin Einaudi
2024-11-19 09:15:51 +01:00
committed by GitHub
parent 654f62ce3c
commit 18b01ca455
7 changed files with 15 additions and 15 deletions

View File

@@ -139,7 +139,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public static RestClient.Builder buildRestClientBuilder(ObjectMapper mapper) {
Consumer<List<HttpMessageConverter<?>>> messageConverters = converters -> {
converters.add(new MappingJackson2HttpMessageConverter(mapper));
converters.add(0, new MappingJackson2HttpMessageConverter(mapper));
};
return RestClient.builder().messageConverters(messageConverters);
@@ -714,4 +714,4 @@ public class ApiClient extends JavaTimeFormatter {
return collectionFormat.collectionToString(values);
}
}
}