Skip to content

Commit f732b71

Browse files
committed
Bring responseBody up-to-speed with regards to response nullability.
1 parent 1b8cc4c commit f732b71

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import com.squareup.moshi.adapter
9898
protected fun guessContentTypeFromByteArray(byteArray: ByteArray): String {
9999
val contentType = try {
100100
URLConnection.guessContentTypeFromStream(byteArray.inputStream())
101-
} catch (io: IOException) {
101+
} catch (_: IOException) {
102102
"application/octet-stream"
103103
}
104104
return contentType
@@ -275,9 +275,8 @@ import com.squareup.moshi.adapter
275275
{{/moshi}}
276276
protected inline fun <reified T: Any?> responseBody(response: Response, mediaType: String? = JSON_MEDIA_TYPE): T? {
277277
val body = response.body
278-
if(body == null) {
279-
return null
280-
} else if (T::class.java == Unit::class.java) {
278+
279+
if (T::class.java == Unit::class.java) {
281280
// No need to parse the body when we're not interested in the body
282281
// Useful when API is returning other Content-Type
283282
return null

0 commit comments

Comments
 (0)