From 5d16e35f11ca06957d1ed287b4dac1bffe9e6910 Mon Sep 17 00:00:00 2001 From: Oyvind Mo Date: Fri, 10 Apr 2026 14:51:44 +0200 Subject: [PATCH] fix [Kotlin]: handle nullable response.body in jvm-okhttp ApiClient template Signed-off-by: Oyvind Mo --- .../libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache index 9560b658a69e..3dd83f71487a 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache @@ -340,7 +340,7 @@ import com.squareup.moshi.adapter @OptIn(ExperimentalStdlibApi::class) {{/moshi}} protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 59945734ce0a..75def196d6e1 100644 --- a/samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/echo_api/kotlin-jvm-okhttp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/others/kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/others/kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index e9ebd04afd9f..6ce203cc15e2 100644 --- a/samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-jvm-okhttp-non-ascii-headers/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/others/kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index abbc2a45d351..9c0e379663b8 100644 --- a/samples/client/others/kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-jvm-okhttp-path-comments/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c72b27a15885..5ae765ef16bd 100644 --- a/samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-allOf-discriminator-kotlinx-serialization/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -287,7 +287,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-allOf-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-array-integer-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-explicit/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-explicit/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 718fdc0f9b2c..8dde76474b55 100644 --- a/samples/client/petstore/kotlin-explicit/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-explicit/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ public open class ApiClient(public val baseUrl: String, public val client: Call. @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index e9ab2444c7d6..d6f907f7947c 100644 --- a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -284,7 +284,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index d5d1cea9c8c2..18912784874d 100644 --- a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -284,7 +284,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 091e0e16d43f..44ee00b60b08 100644 --- a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -288,7 +288,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 5c4098729a5a..f4b11927a365 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -287,7 +287,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 28d375d29e3e..0197390a824a 100644 --- a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 8059dde4e5fa..aff54eb43a1b 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ internal open class ApiClient(val baseUrl: String, val client: Call.Factory = de @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 51729ff8cf67..8f316e316b2e 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c72b27a15885..5ae765ef16bd 100644 --- a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -287,7 +287,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie } protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 13624eb01a8b..3f8f02e86937 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -285,7 +285,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie @OptIn(ExperimentalStdlibApi::class) protected inline fun responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? { - val body = response.body + val body = response.body ?: return null if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body