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 66e77122a811..ea19748fbfbc 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 @@ -25,6 +25,7 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter import retrofit2.converter.scalars.ScalarsConverterFactory {{#useRxJava}} import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory @@ -55,7 +56,8 @@ import okhttp3.MediaType.Companion.toMediaType private var baseUrl: String = defaultBasePath, private val okHttpClientBuilder: OkHttpClient.Builder? = null{{^kotlinx_serialization}}, private val serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder{{/kotlinx_serialization}}, - private val okHttpClient : OkHttpClient? = null + private val okHttpClient : OkHttpClient? = null, + private val converterFactory: Converter.Factory? = null, ) { private val apiAuthorizations = mutableMapOf() var logger: ((String) -> Unit)? = null @@ -81,6 +83,11 @@ import okhttp3.MediaType.Companion.toMediaType {{#kotlinx_serialization}} .addConverterFactory(jvmJson.asConverterFactory("application/json".toMediaType())) {{/kotlinx_serialization}} + .apply { + if (converterFactory != null) { + addConverterFactory(converterFactory) + } + } } private val clientBuilder: OkHttpClient.Builder by lazy { diff --git a/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index b721ee141b04..a5aaa332be80 100644 --- a/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2-kotlinx_serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -11,6 +11,7 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter import retrofit2.converter.scalars.ScalarsConverterFactory import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory @@ -20,7 +21,8 @@ import okhttp3.MediaType.Companion.toMediaType class ApiClient( private var baseUrl: String = defaultBasePath, private val okHttpClientBuilder: OkHttpClient.Builder? = null, - private val okHttpClient : OkHttpClient? = null + private val okHttpClient : OkHttpClient? = null, + private val converterFactory: Converter.Factory? = null, ) { private val apiAuthorizations = mutableMapOf() var logger: ((String) -> Unit)? = null @@ -30,6 +32,11 @@ class ApiClient( .baseUrl(baseUrl) .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(jvmJson.asConverterFactory("application/json".toMediaType())) + .apply { + if (converterFactory != null) { + addConverterFactory(converterFactory) + } + } } private val clientBuilder: OkHttpClient.Builder by lazy { diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1b1edd60ae21..cc63b570177a 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -11,6 +11,7 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory import com.squareup.moshi.Moshi @@ -21,7 +22,8 @@ class ApiClient( private var baseUrl: String = defaultBasePath, private val okHttpClientBuilder: OkHttpClient.Builder? = null, private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder, - private val okHttpClient : OkHttpClient? = null + private val okHttpClient : OkHttpClient? = null, + private val converterFactory: Converter.Factory? = null, ) { private val apiAuthorizations = mutableMapOf() var logger: ((String) -> Unit)? = null @@ -33,6 +35,11 @@ class ApiClient( .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) .addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build())) + .apply { + if (converterFactory != null) { + addConverterFactory(converterFactory) + } + } } private val clientBuilder: OkHttpClient.Builder by lazy { diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 667359c1f227..bee954129e6b 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -11,6 +11,7 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import retrofit2.Retrofit import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Converter import retrofit2.converter.scalars.ScalarsConverterFactory import com.squareup.moshi.Moshi import retrofit2.converter.moshi.MoshiConverterFactory @@ -20,7 +21,8 @@ class ApiClient( private var baseUrl: String = defaultBasePath, private val okHttpClientBuilder: OkHttpClient.Builder? = null, private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder, - private val okHttpClient : OkHttpClient? = null + private val okHttpClient : OkHttpClient? = null, + private val converterFactory: Converter.Factory? = null, ) { private val apiAuthorizations = mutableMapOf() var logger: ((String) -> Unit)? = null @@ -30,6 +32,11 @@ class ApiClient( .baseUrl(baseUrl) .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(MoshiConverterFactory.create(serializerBuilder.build())) + .apply { + if (converterFactory != null) { + addConverterFactory(converterFactory) + } + } } private val clientBuilder: OkHttpClient.Builder by lazy {