diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache index c5d0f13b5e1..71f26c258f2 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/build.gradle.mustache @@ -53,6 +53,11 @@ test { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + {{^doNotUseRxAndCoroutines}} + {{#useCoroutines}} + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1" + {{/useCoroutines}} + {{/doNotUseRxAndCoroutines}} {{#moshi}} {{^moshiCodeGen}} implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache index dd97f0ae30f..fe59147907a 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/api.mustache @@ -4,6 +4,12 @@ package {{apiPackage}} {{#imports}}import {{import}} {{/imports}} +{{^doNotUseRxAndCoroutines}} +{{#useCoroutines}} +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +{{/useCoroutines}} +{{/doNotUseRxAndCoroutines}} import {{packageName}}.infrastructure.ApiClient import {{packageName}}.infrastructure.ClientException import {{packageName}}.infrastructure.ClientError @@ -40,7 +46,7 @@ import {{packageName}}.infrastructure.toMultiValue {{#isDeprecated}} @Deprecated(message = "This operation is deprecated.") {{/isDeprecated}} - {{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}} { + {{^doNotUseRxAndCoroutines}}{{#useCoroutines}}suspend {{/useCoroutines}}{{/doNotUseRxAndCoroutines}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{{dataType}}}{{^required}}?{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) : {{#returnType}}{{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}{{^doNotUseRxAndCoroutines}}{{#useCoroutines}} = withContext(Dispatchers.IO){{/useCoroutines}}{{/doNotUseRxAndCoroutines}} { {{#isDeprecated}} @Suppress("DEPRECATION") {{/isDeprecated}} @@ -50,7 +56,7 @@ import {{packageName}}.infrastructure.toMultiValue localVariableConfig ) - return when (localVarResponse.responseType) { + return{{^doNotUseRxAndCoroutines}}{{#useCoroutines}}@withContext{{/useCoroutines}}{{/doNotUseRxAndCoroutines}} when (localVarResponse.responseType) { ResponseType.Success -> {{#returnType}}(localVarResponse as Success<*>).data as {{{returnType}}}{{#nullableReturnType}}?{{/nullableReturnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}} ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/build.gradle b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/build.gradle index 5cad8581cb6..70d79ab6932 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/build.gradle +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/build.gradle @@ -29,6 +29,7 @@ test { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1" implementation "com.google.code.gson:gson:2.8.7" implementation "com.squareup.okhttp3:okhttp:4.9.1" testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2" diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 74174279b14..9ae9e8f0890 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -14,6 +14,8 @@ package org.openapitools.client.apis import org.openapitools.client.models.ApiResponse import org.openapitools.client.models.Pet +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext import org.openapitools.client.infrastructure.ApiClient import org.openapitools.client.infrastructure.ClientException import org.openapitools.client.infrastructure.ClientError @@ -44,14 +46,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun addPet(body: Pet) : Unit { + suspend fun addPet(body: Pet) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = addPetRequestConfig(body = body) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -97,14 +99,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit { + suspend fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = deletePetRequestConfig(petId = petId, apiKey = apiKey) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -152,14 +154,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun findPetsByStatus(status: kotlin.collections.List) : kotlin.collections.List { + suspend fun findPetsByStatus(status: kotlin.collections.List) : kotlin.collections.List = withContext(Dispatchers.IO) { val localVariableConfig = findPetsByStatusRequestConfig(status = status) val localVarResponse = request>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -209,7 +211,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) @Deprecated(message = "This operation is deprecated.") - suspend fun findPetsByTags(tags: kotlin.collections.List) : kotlin.collections.List { + suspend fun findPetsByTags(tags: kotlin.collections.List) : kotlin.collections.List = withContext(Dispatchers.IO) { @Suppress("DEPRECATION") val localVariableConfig = findPetsByTagsRequestConfig(tags = tags) @@ -217,7 +219,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -267,14 +269,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun getPetById(petId: kotlin.Long) : Pet { + suspend fun getPetById(petId: kotlin.Long) : Pet = withContext(Dispatchers.IO) { val localVariableConfig = getPetByIdRequestConfig(petId = petId) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as Pet ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -319,14 +321,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun updatePet(body: Pet) : Unit { + suspend fun updatePet(body: Pet) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = updatePetRequestConfig(body = body) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -373,14 +375,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit { + suspend fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = updatePetWithFormRequestConfig(petId = petId, name = name, status = status) val localVarResponse = request, Unit>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -430,14 +432,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse { + suspend fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: java.io.File?) : ApiResponse = withContext(Dispatchers.IO) { val localVariableConfig = uploadFileRequestConfig(petId = petId, additionalMetadata = additionalMetadata, file = file) val localVarResponse = request, ApiResponse>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as ApiResponse ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index e4ed2245f6f..e9120ae8209 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -13,6 +13,8 @@ package org.openapitools.client.apis import org.openapitools.client.models.Order +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext import org.openapitools.client.infrastructure.ApiClient import org.openapitools.client.infrastructure.ClientException import org.openapitools.client.infrastructure.ClientError @@ -43,14 +45,14 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun deleteOrder(orderId: kotlin.String) : Unit { + suspend fun deleteOrder(orderId: kotlin.String) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = deleteOrderRequestConfig(orderId = orderId) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -95,14 +97,14 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun getInventory() : kotlin.collections.Map { + suspend fun getInventory() : kotlin.collections.Map = withContext(Dispatchers.IO) { val localVariableConfig = getInventoryRequestConfig() val localVarResponse = request>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -147,14 +149,14 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun getOrderById(orderId: kotlin.Long) : Order { + suspend fun getOrderById(orderId: kotlin.Long) : Order = withContext(Dispatchers.IO) { val localVariableConfig = getOrderByIdRequestConfig(orderId = orderId) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -200,14 +202,14 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun placeOrder(body: Order) : Order { + suspend fun placeOrder(body: Order) : Order = withContext(Dispatchers.IO) { val localVariableConfig = placeOrderRequestConfig(body = body) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as Order ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 44f24c941f8..da3c33f134b 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -13,6 +13,8 @@ package org.openapitools.client.apis import org.openapitools.client.models.User +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext import org.openapitools.client.infrastructure.ApiClient import org.openapitools.client.infrastructure.ClientException import org.openapitools.client.infrastructure.ClientError @@ -43,14 +45,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun createUser(body: User) : Unit { + suspend fun createUser(body: User) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = createUserRequestConfig(body = body) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -95,14 +97,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun createUsersWithArrayInput(body: kotlin.collections.List) : Unit { + suspend fun createUsersWithArrayInput(body: kotlin.collections.List) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = createUsersWithArrayInputRequestConfig(body = body) val localVarResponse = request, Unit>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -147,14 +149,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun createUsersWithListInput(body: kotlin.collections.List) : Unit { + suspend fun createUsersWithListInput(body: kotlin.collections.List) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = createUsersWithListInputRequestConfig(body = body) val localVarResponse = request, Unit>( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -199,14 +201,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun deleteUser(username: kotlin.String) : Unit { + suspend fun deleteUser(username: kotlin.String) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = deleteUserRequestConfig(username = username) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -252,14 +254,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun getUserByName(username: kotlin.String) : User { + suspend fun getUserByName(username: kotlin.String) : User = withContext(Dispatchers.IO) { val localVariableConfig = getUserByNameRequestConfig(username = username) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as User ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -306,14 +308,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { */ @Suppress("UNCHECKED_CAST") @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String { + suspend fun loginUser(username: kotlin.String, password: kotlin.String) : kotlin.String = withContext(Dispatchers.IO) { val localVariableConfig = loginUserRequestConfig(username = username, password = password) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.String ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -362,14 +364,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun logoutUser() : Unit { + suspend fun logoutUser() : Unit = withContext(Dispatchers.IO) { val localVariableConfig = logoutUserRequestConfig() val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") @@ -414,14 +416,14 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) { * @throws ServerException If the API returns a server error response */ @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class) - suspend fun updateUser(username: kotlin.String, body: User) : Unit { + suspend fun updateUser(username: kotlin.String, body: User) : Unit = withContext(Dispatchers.IO) { val localVariableConfig = updateUserRequestConfig(username = username, body = body) val localVarResponse = request( localVariableConfig ) - return when (localVarResponse.responseType) { + return@withContext when (localVarResponse.responseType) { ResponseType.Success -> Unit ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")