forked from loafle/openapi-generator-original
[kotlin][client] define kotlin coroutines context (#9936)
* [kotlin][client] define coroutines context * [kotlin][client] update sample projects * [kotlin][client] add missing kotlinx coroutines dependency * [kotlin][client] update sample projects
This commit is contained in:
parent
7573234a4c
commit
26f998b043
@ -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"
|
||||
|
@ -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.")
|
||||
|
@ -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"
|
||||
|
@ -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<Pet, 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.")
|
||||
@ -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<Unit, 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.")
|
||||
@ -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.String>) : kotlin.collections.List<Pet> {
|
||||
suspend fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>) : kotlin.collections.List<Pet> = withContext(Dispatchers.IO) {
|
||||
val localVariableConfig = findPetsByStatusRequestConfig(status = status)
|
||||
|
||||
val localVarResponse = request<Unit, kotlin.collections.List<Pet>>(
|
||||
localVariableConfig
|
||||
)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
return@withContext when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List<Pet>
|
||||
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.String>) : kotlin.collections.List<Pet> {
|
||||
suspend fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>) : kotlin.collections.List<Pet> = 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<Pet>
|
||||
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<Unit, Pet>(
|
||||
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<Pet, 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.")
|
||||
@ -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<Map<String, Any?>, 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<Map<String, Any?>, 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.")
|
||||
|
@ -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<Unit, 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.")
|
||||
@ -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<kotlin.String, kotlin.Int> {
|
||||
suspend fun getInventory() : kotlin.collections.Map<kotlin.String, kotlin.Int> = withContext(Dispatchers.IO) {
|
||||
val localVariableConfig = getInventoryRequestConfig()
|
||||
|
||||
val localVarResponse = request<Unit, kotlin.collections.Map<kotlin.String, kotlin.Int>>(
|
||||
localVariableConfig
|
||||
)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
return@withContext when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.Map<kotlin.String, kotlin.Int>
|
||||
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<Unit, Order>(
|
||||
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<Order, Order>(
|
||||
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.")
|
||||
|
@ -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<User, 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.")
|
||||
@ -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<User>) : Unit {
|
||||
suspend fun createUsersWithArrayInput(body: kotlin.collections.List<User>) : Unit = withContext(Dispatchers.IO) {
|
||||
val localVariableConfig = createUsersWithArrayInputRequestConfig(body = body)
|
||||
|
||||
val localVarResponse = request<kotlin.collections.List<User>, 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<User>) : Unit {
|
||||
suspend fun createUsersWithListInput(body: kotlin.collections.List<User>) : Unit = withContext(Dispatchers.IO) {
|
||||
val localVariableConfig = createUsersWithListInputRequestConfig(body = body)
|
||||
|
||||
val localVarResponse = request<kotlin.collections.List<User>, 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<Unit, 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.")
|
||||
@ -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<Unit, User>(
|
||||
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<Unit, kotlin.String>(
|
||||
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<Unit, 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.")
|
||||
@ -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<User, 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.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user