Skip to content

Commit 546400c

Browse files
committed
[Kotlin][okhttp] replace okhttpclient with callfactory
1 parent deb007b commit 546400c

File tree

66 files changed

+132
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+132
-111
lines changed

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package {{apiPackage}}
33

44
import java.io.IOException
5-
import okhttp3.OkHttpClient
5+
import okhttp3.Call
66
import okhttp3.HttpUrl
77

88
{{#imports}}import {{import}}
@@ -48,7 +48,7 @@ import {{packageName}}.infrastructure.Success
4848
import {{packageName}}.infrastructure.toMultiValue
4949

5050
{{#operations}}
51-
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
51+
{{#nonPublicApi}}internal {{/nonPublicApi}}class {{classname}}(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
5252
companion object {
5353
@JvmStatic
5454
val defaultBasePath: String by lazy {

modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package {{packageName}}.infrastructure
33
{{#supportAndroidApiLevel25AndBelow}}
44
import android.os.Build
55
{{/supportAndroidApiLevel25AndBelow}}
6+
import okhttp3.Call
67
import okhttp3.OkHttpClient
78
import okhttp3.RequestBody
89
import okhttp3.RequestBody.Companion.asRequestBody
@@ -60,7 +61,7 @@ import com.squareup.moshi.adapter
6061

6162
{{#nonPublicApi}}internal {{/nonPublicApi}}val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
6263

63-
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
64+
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
6465
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
6566
protected const val ContentType = "Content-Type"
6667
protected const val Accept = "Accept"

samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222

@@ -36,7 +36,7 @@ import org.openapitools.client.infrastructure.ResponseType
3636
import org.openapitools.client.infrastructure.Success
3737
import org.openapitools.client.infrastructure.toMultiValue
3838

39-
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
39+
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4040
companion object {
4141
@JvmStatic
4242
val defaultBasePath: String by lazy {

samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/apis/BirdApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.Bird
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class BirdApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class BirdApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222

@@ -36,7 +36,7 @@ import org.openapitools.client.infrastructure.ResponseType
3636
import org.openapitools.client.infrastructure.Success
3737
import org.openapitools.client.infrastructure.toMultiValue
3838

39-
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
39+
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4040
companion object {
4141
@JvmStatic
4242
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.Apa
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222

@@ -36,7 +36,7 @@ import org.openapitools.client.infrastructure.ResponseType
3636
import org.openapitools.client.infrastructure.Success
3737
import org.openapitools.client.infrastructure.toMultiValue
3838

39-
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
39+
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4040
companion object {
4141
@JvmStatic
4242
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/apis/DefaultApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.ModelWithEnumPropertyHavingDefault
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class DefaultApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.squareup.moshi.adapter
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/PetApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.ModelApiResponse
@@ -38,7 +38,7 @@ import org.openapitools.client.infrastructure.ResponseType
3838
import org.openapitools.client.infrastructure.Success
3939
import org.openapitools.client.infrastructure.toMultiValue
4040

41-
class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
41+
class PetApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4242
companion object {
4343
@JvmStatic
4444
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.Order
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class StoreApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/apis/UserApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.User
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class UserApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.google.gson.reflect.TypeToken
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/apis/PetApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.ModelApiResponse
@@ -38,7 +38,7 @@ import org.openapitools.client.infrastructure.ResponseType
3838
import org.openapitools.client.infrastructure.Success
3939
import org.openapitools.client.infrastructure.toMultiValue
4040

41-
class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
41+
class PetApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4242
companion object {
4343
@JvmStatic
4444
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.Order
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class StoreApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/apis/UserApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.User
@@ -37,7 +37,7 @@ import org.openapitools.client.infrastructure.ResponseType
3737
import org.openapitools.client.infrastructure.Success
3838
import org.openapitools.client.infrastructure.toMultiValue
3939

40-
class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
40+
class UserApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4141
companion object {
4242
@JvmStatic
4343
val defaultBasePath: String by lazy {

samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.client.infrastructure
22

3+
import okhttp3.Call
34
import okhttp3.OkHttpClient
45
import okhttp3.RequestBody
56
import okhttp3.RequestBody.Companion.asRequestBody
@@ -31,7 +32,7 @@ import com.fasterxml.jackson.core.type.TypeReference
3132

3233
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
3334

34-
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
35+
open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClient) {
3536
companion object {
3637
protected const val ContentType = "Content-Type"
3738
protected const val Accept = "Accept"

samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.openapitools.client.apis
1717

1818
import java.io.IOException
19-
import okhttp3.OkHttpClient
19+
import okhttp3.Call
2020
import okhttp3.HttpUrl
2121

2222
import org.openapitools.client.models.ModelApiResponse
@@ -39,7 +39,7 @@ import org.openapitools.client.infrastructure.ResponseType
3939
import org.openapitools.client.infrastructure.Success
4040
import org.openapitools.client.infrastructure.toMultiValue
4141

42-
class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
42+
class PetApi(basePath: kotlin.String = defaultBasePath, client: Call.Factory = ApiClient.defaultClient) : ApiClient(basePath, client) {
4343
companion object {
4444
@JvmStatic
4545
val defaultBasePath: String by lazy {

0 commit comments

Comments
 (0)