@@ -14,6 +14,8 @@ package org.openapitools.client.apis
14
14
import org.openapitools.client.models.ApiResponse
15
15
import org.openapitools.client.models.Pet
16
16
17
+ import kotlinx.coroutines.Dispatchers
18
+ import kotlinx.coroutines.withContext
17
19
import org.openapitools.client.infrastructure.ApiClient
18
20
import org.openapitools.client.infrastructure.ClientException
19
21
import org.openapitools.client.infrastructure.ClientError
@@ -44,14 +46,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
44
46
* @throws ServerException If the API returns a server error response
45
47
*/
46
48
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
47
- suspend fun addPet (body : Pet ) : Unit {
49
+ suspend fun addPet (body : Pet ) : Unit = withContext( Dispatchers . IO ) {
48
50
val localVariableConfig = addPetRequestConfig(body = body)
49
51
50
52
val localVarResponse = request<Pet , Unit >(
51
53
localVariableConfig
52
54
)
53
55
54
- return when (localVarResponse.responseType) {
56
+ return @withContext when (localVarResponse.responseType) {
55
57
ResponseType .Success -> Unit
56
58
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
57
59
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -97,14 +99,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
97
99
* @throws ServerException If the API returns a server error response
98
100
*/
99
101
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
100
- suspend fun deletePet (petId : kotlin.Long , apiKey : kotlin.String? ) : Unit {
102
+ suspend fun deletePet (petId : kotlin.Long , apiKey : kotlin.String? ) : Unit = withContext( Dispatchers . IO ) {
101
103
val localVariableConfig = deletePetRequestConfig(petId = petId, apiKey = apiKey)
102
104
103
105
val localVarResponse = request<Unit , Unit >(
104
106
localVariableConfig
105
107
)
106
108
107
- return when (localVarResponse.responseType) {
109
+ return @withContext when (localVarResponse.responseType) {
108
110
ResponseType .Success -> Unit
109
111
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
110
112
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -152,14 +154,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
152
154
*/
153
155
@Suppress(" UNCHECKED_CAST" )
154
156
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
155
- suspend fun findPetsByStatus (status : kotlin.collections.List <kotlin.String >) : kotlin.collections.List <Pet > {
157
+ suspend fun findPetsByStatus (status : kotlin.collections.List <kotlin.String >) : kotlin.collections.List <Pet > = withContext( Dispatchers . IO ) {
156
158
val localVariableConfig = findPetsByStatusRequestConfig(status = status)
157
159
158
160
val localVarResponse = request<Unit , kotlin.collections.List <Pet >>(
159
161
localVariableConfig
160
162
)
161
163
162
- return when (localVarResponse.responseType) {
164
+ return @withContext when (localVarResponse.responseType) {
163
165
ResponseType .Success -> (localVarResponse as Success <* >).data as kotlin.collections.List <Pet >
164
166
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
165
167
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -209,15 +211,15 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
209
211
@Suppress(" UNCHECKED_CAST" )
210
212
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
211
213
@Deprecated(message = " This operation is deprecated." )
212
- suspend fun findPetsByTags (tags : kotlin.collections.List <kotlin.String >) : kotlin.collections.List <Pet > {
214
+ suspend fun findPetsByTags (tags : kotlin.collections.List <kotlin.String >) : kotlin.collections.List <Pet > = withContext( Dispatchers . IO ) {
213
215
@Suppress(" DEPRECATION" )
214
216
val localVariableConfig = findPetsByTagsRequestConfig(tags = tags)
215
217
216
218
val localVarResponse = request<Unit , kotlin.collections.List <Pet >>(
217
219
localVariableConfig
218
220
)
219
221
220
- return when (localVarResponse.responseType) {
222
+ return @withContext when (localVarResponse.responseType) {
221
223
ResponseType .Success -> (localVarResponse as Success <* >).data as kotlin.collections.List <Pet >
222
224
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
223
225
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -267,14 +269,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
267
269
*/
268
270
@Suppress(" UNCHECKED_CAST" )
269
271
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
270
- suspend fun getPetById (petId : kotlin.Long ) : Pet {
272
+ suspend fun getPetById (petId : kotlin.Long ) : Pet = withContext( Dispatchers . IO ) {
271
273
val localVariableConfig = getPetByIdRequestConfig(petId = petId)
272
274
273
275
val localVarResponse = request<Unit , Pet >(
274
276
localVariableConfig
275
277
)
276
278
277
- return when (localVarResponse.responseType) {
279
+ return @withContext when (localVarResponse.responseType) {
278
280
ResponseType .Success -> (localVarResponse as Success <* >).data as Pet
279
281
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
280
282
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -319,14 +321,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
319
321
* @throws ServerException If the API returns a server error response
320
322
*/
321
323
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
322
- suspend fun updatePet (body : Pet ) : Unit {
324
+ suspend fun updatePet (body : Pet ) : Unit = withContext( Dispatchers . IO ) {
323
325
val localVariableConfig = updatePetRequestConfig(body = body)
324
326
325
327
val localVarResponse = request<Pet , Unit >(
326
328
localVariableConfig
327
329
)
328
330
329
- return when (localVarResponse.responseType) {
331
+ return @withContext when (localVarResponse.responseType) {
330
332
ResponseType .Success -> Unit
331
333
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
332
334
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -373,14 +375,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
373
375
* @throws ServerException If the API returns a server error response
374
376
*/
375
377
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
376
- suspend fun updatePetWithForm (petId : kotlin.Long , name : kotlin.String? , status : kotlin.String? ) : Unit {
378
+ suspend fun updatePetWithForm (petId : kotlin.Long , name : kotlin.String? , status : kotlin.String? ) : Unit = withContext( Dispatchers . IO ) {
377
379
val localVariableConfig = updatePetWithFormRequestConfig(petId = petId, name = name, status = status)
378
380
379
381
val localVarResponse = request<Map <String , Any ?>, Unit > (
380
382
localVariableConfig
381
383
)
382
384
383
- return when (localVarResponse.responseType) {
385
+ return @withContext when (localVarResponse.responseType) {
384
386
ResponseType .Success -> Unit
385
387
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
386
388
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
@@ -430,14 +432,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
430
432
*/
431
433
@Suppress(" UNCHECKED_CAST" )
432
434
@Throws(UnsupportedOperationException ::class , ClientException ::class , ServerException ::class )
433
- suspend fun uploadFile (petId : kotlin.Long , additionalMetadata : kotlin.String? , file : java.io.File ? ) : ApiResponse {
435
+ suspend fun uploadFile (petId : kotlin.Long , additionalMetadata : kotlin.String? , file : java.io.File ? ) : ApiResponse = withContext( Dispatchers . IO ) {
434
436
val localVariableConfig = uploadFileRequestConfig(petId = petId, additionalMetadata = additionalMetadata, file = file)
435
437
436
438
val localVarResponse = request<Map <String , Any ?>, ApiResponse > (
437
439
localVariableConfig
438
440
)
439
441
440
- return when (localVarResponse.responseType) {
442
+ return @withContext when (localVarResponse.responseType) {
441
443
ResponseType .Success -> (localVarResponse as Success <* >).data as ApiResponse
442
444
ResponseType .Informational -> throw UnsupportedOperationException (" Client does not support Informational responses." )
443
445
ResponseType .Redirection -> throw UnsupportedOperationException (" Client does not support Redirection responses." )
0 commit comments