From c2ec0bafdf9f7e50351fcbb024e8b4e944ba2d25 Mon Sep 17 00:00:00 2001 From: Yonatan Karp-Rudin Date: Mon, 22 Jan 2024 18:09:45 +0100 Subject: [PATCH] Pass ObjectMapper to JacksonConverterFactory (#17673) This commit fixes an issue where the object mapper is not passed to the JacksonConverterFactory. The issue causing the serialization to fail when passing to the ApiClient a pre-configured mapper object (e.g. the primary bean of SpringBoot). With this fix, the bean would be correctly passed to the factory, and the serialization would work "out of the box" for the pre-configured bean. --- .../jvm-retrofit2/infrastructure/ApiClient.kt.mustache | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache index 52df6a87a62..a2a4a20ae73 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache @@ -90,7 +90,7 @@ import okhttp3.MediaType.Companion.toMediaType kotlinxSerializationJson.asConverterFactory("application/json".toMediaType()), {{/kotlinx_serialization}} {{#jackson}} - JacksonConverterFactory.create(), + JacksonConverterFactory.create(serializerBuilder), {{/jackson}} ) ) { diff --git a/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1a1b4fd85fa..14a9210110a 100644 --- a/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -28,7 +28,7 @@ class ApiClient( ), private val converterFactories: List = listOf( ScalarsConverterFactory.create(), - JacksonConverterFactory.create(), + JacksonConverterFactory.create(serializerBuilder), ) ) { private val apiAuthorizations = mutableMapOf() diff --git a/samples/client/petstore/kotlin-retrofit2-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1a1b4fd85fa..14a9210110a 100644 --- a/samples/client/petstore/kotlin-retrofit2-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -28,7 +28,7 @@ class ApiClient( ), private val converterFactories: List = listOf( ScalarsConverterFactory.create(), - JacksonConverterFactory.create(), + JacksonConverterFactory.create(serializerBuilder), ) ) { private val apiAuthorizations = mutableMapOf()