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 a0251071b21..e3962e0c0f2 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 @@ -19,7 +19,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory class ApiClient( private var baseUrl: String = defaultBasePath, private val okHttpClientBuilder: OkHttpClient.Builder? = null, - private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder + private val serializerBuilder: Moshi.Builder = Serializer.moshiBuilder, + private val okHttpClient : OkHttpClient? = null ) { private val apiAuthorizations = mutableMapOf() var logger: ((String) -> Unit)? = null @@ -174,7 +175,9 @@ class ApiClient( } fun createService(serviceClass: Class): S { - return retrofitBuilder.client(clientBuilder.build()).build().create(serviceClass) + var usedClient: OkHttpClient? = null + this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()} + return retrofitBuilder.client(usedClient).build().create(serviceClass) } private fun normalizeBaseUrl() {