forked from loafle/openapi-generator-original
[kotlin][jvm-retrofit2] Better code for OkHttp client passed to Retrofit builder (#7556)
* Better code for building Retrofit By removing the nullable `usedClient` passed to Retrofit, the code is compatible with newer Retrofit versions which don't allow null as client. * Updated Kotlin retrofit2 samples ApiClient
This commit is contained in:
parent
b733312707
commit
1dec9ebfb8
@ -287,8 +287,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
}
|
||||
|
||||
fun <S> createService(serviceClass: Class<S>): 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)
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,7 @@ class ApiClient(
|
||||
}
|
||||
|
||||
fun <S> createService(serviceClass: Class<S>): 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)
|
||||
}
|
||||
|
||||
|
@ -172,8 +172,7 @@ class ApiClient(
|
||||
}
|
||||
|
||||
fun <S> createService(serviceClass: Class<S>): 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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user