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 5026c3f0e07..d556f0e9869 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 @@ -287,8 +287,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory } fun createService(serviceClass: Class): S { - var usedClient: OkHttpClient? = null - this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()} + val usedClient = this.okHttpClient ?: clientBuilder.build() return retrofitBuilder.client(usedClient).build().create(serviceClass) } @@ -313,4 +312,4 @@ import retrofit2.converter.moshi.MoshiConverterFactory System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}") } } -} \ No newline at end of file +} 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 e3962e0c0f2..f23b3308a41 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 @@ -175,8 +175,7 @@ class ApiClient( } fun createService(serviceClass: Class): S { - var usedClient: OkHttpClient? = null - this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()} + val usedClient = this.okHttpClient ?: clientBuilder.build() return retrofitBuilder.client(usedClient).build().create(serviceClass) } @@ -201,4 +200,4 @@ class ApiClient( System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2") } } -} \ No newline at end of file +} 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 8f822585a6e..c8078936eb5 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 @@ -172,8 +172,7 @@ class ApiClient( } fun createService(serviceClass: Class): S { - var usedClient: OkHttpClient? = null - this.okHttpClient?.let { usedClient = it } ?: run {usedClient = clientBuilder.build()} + val usedClient = this.okHttpClient ?: clientBuilder.build() return retrofitBuilder.client(usedClient).build().create(serviceClass) } @@ -198,4 +197,4 @@ class ApiClient( System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2") } } -} \ No newline at end of file +}