From b936d72dfa3ad499722b98b9708198f59044ab03 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 13 Aug 2019 08:38:00 -0400 Subject: [PATCH] [kotlin] Change Kotlin client exceptions to expose lack of support as UnsupportedOperationException rather than NotImplementedException. (#3611) * [kotlin] Throw catchable exceptions rather than TODO() * [kotlin] Regenerate samples --- .../main/resources/kotlin-client/api.mustache | 4 +-- .../infrastructure/ApiClient.kt.mustache | 6 ++-- .../org/openapitools/client/apis/PetApi.kt | 32 +++++++++---------- .../org/openapitools/client/apis/StoreApi.kt | 16 +++++----- .../org/openapitools/client/apis/UserApi.kt | 32 +++++++++---------- .../client/infrastructure/ApiClient.kt | 6 ++-- .../org/openapitools/client/apis/PetApi.kt | 32 +++++++++---------- .../org/openapitools/client/apis/StoreApi.kt | 16 +++++----- .../org/openapitools/client/apis/UserApi.kt | 32 +++++++++---------- .../client/infrastructure/ApiClient.kt | 6 ++-- .../org/openapitools/client/apis/StoreApi.kt | 4 +-- .../org/openapitools/client/apis/PetApi.kt | 32 +++++++++---------- .../org/openapitools/client/apis/StoreApi.kt | 16 +++++----- .../org/openapitools/client/apis/UserApi.kt | 32 +++++++++---------- .../client/infrastructure/ApiClient.kt | 6 ++-- 15 files changed, 136 insertions(+), 136 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache index 6a38138788e..9ee04616e1d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache @@ -44,8 +44,8 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base return when (response.responseType) { ResponseType.Success -> {{#returnType}}(response as Success<*>).data as {{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache index 20a0e6a54f7..61dda50372d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache @@ -46,9 +46,9 @@ open class ApiClient(val baseUrl: String) { mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody( mediaType.toMediaTypeOrNull() ) - mediaType == XmlMediaType -> TODO("xml not currently supported.") + mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.") // TODO: this should be extended with other serializers - else -> TODO("requestBody currently only supports JSON body and File body.") + else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.") } protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { @@ -61,7 +61,7 @@ open class ApiClient(val baseUrl: String) { } return when(mediaType) { JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) - else -> TODO("responseBody currently only supports JSON body.") + else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") } } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 36c7ad82613..15f63f2a1b5 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -51,8 +51,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -82,8 +82,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -113,8 +113,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -144,8 +144,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -175,8 +175,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Pet - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -205,8 +205,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -237,8 +237,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -270,8 +270,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as ApiResponse - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 891b91d6814..90d681f8f34 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -50,8 +50,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -111,8 +111,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -142,8 +142,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index ea538f439a1..daaaeae3150 100644 --- a/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-string/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -50,8 +50,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -110,8 +110,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -140,8 +140,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -171,8 +171,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as User - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -203,8 +203,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.String - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -232,8 +232,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -263,8 +263,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } 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 8a7cc13a29c..75a49d0fa43 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 @@ -46,9 +46,9 @@ open class ApiClient(val baseUrl: String) { mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody( mediaType.toMediaTypeOrNull() ) - mediaType == XmlMediaType -> TODO("xml not currently supported.") + mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.") // TODO: this should be extended with other serializers - else -> TODO("requestBody currently only supports JSON body and File body.") + else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.") } protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { @@ -61,7 +61,7 @@ open class ApiClient(val baseUrl: String) { } return when(mediaType) { JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) - else -> TODO("responseBody currently only supports JSON body.") + else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") } } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 36c7ad82613..15f63f2a1b5 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -51,8 +51,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -82,8 +82,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -113,8 +113,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -144,8 +144,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -175,8 +175,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Pet - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -205,8 +205,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -237,8 +237,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -270,8 +270,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as ApiResponse - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 891b91d6814..90d681f8f34 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -50,8 +50,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -111,8 +111,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -142,8 +142,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index ea538f439a1..daaaeae3150 100644 --- a/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-threetenbp/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -50,8 +50,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -110,8 +110,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -140,8 +140,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -171,8 +171,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as User - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -203,8 +203,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.String - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -232,8 +232,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -263,8 +263,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } 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 8a7cc13a29c..75a49d0fa43 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 @@ -46,9 +46,9 @@ open class ApiClient(val baseUrl: String) { mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody( mediaType.toMediaTypeOrNull() ) - mediaType == XmlMediaType -> TODO("xml not currently supported.") + mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.") // TODO: this should be extended with other serializers - else -> TODO("requestBody currently only supports JSON body and File body.") + else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.") } protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { @@ -61,7 +61,7 @@ open class ApiClient(val baseUrl: String) { } return when(mediaType) { JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) - else -> TODO("responseBody currently only supports JSON body.") + else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") } } diff --git a/samples/client/petstore/kotlin/bin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin/bin/org/openapitools/client/apis/StoreApi.kt index bead1dcc359..48ecd493a1e 100644 --- a/samples/client/petstore/kotlin/bin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin/bin/org/openapitools/client/apis/StoreApi.kt @@ -40,8 +40,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational reponses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Rediration responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") else -> throw kotlin.IllegalStateException("Undefined ResponseType.") diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 36c7ad82613..15f63f2a1b5 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -51,8 +51,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -82,8 +82,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -113,8 +113,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -144,8 +144,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -175,8 +175,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Pet - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -205,8 +205,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -237,8 +237,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -270,8 +270,8 @@ class PetApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCli return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as ApiResponse - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 891b91d6814..90d681f8f34 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -50,8 +50,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.collections.Map - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -111,8 +111,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -142,8 +142,8 @@ class StoreApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiC return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as Order - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } diff --git a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index ea538f439a1..daaaeae3150 100644 --- a/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -50,8 +50,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -80,8 +80,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -110,8 +110,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -140,8 +140,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -171,8 +171,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as User - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -203,8 +203,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.String - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -232,8 +232,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } @@ -263,8 +263,8 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl return when (response.responseType) { ResponseType.Success -> Unit - ResponseType.Informational -> TODO() - ResponseType.Redirection -> TODO() + ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.") + ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.") ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") } 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 8a7cc13a29c..75a49d0fa43 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 @@ -46,9 +46,9 @@ open class ApiClient(val baseUrl: String) { mediaType == JsonMediaType -> Serializer.moshi.adapter(T::class.java).toJson(content).toRequestBody( mediaType.toMediaTypeOrNull() ) - mediaType == XmlMediaType -> TODO("xml not currently supported.") + mediaType == XmlMediaType -> throw UnsupportedOperationException("xml not currently supported.") // TODO: this should be extended with other serializers - else -> TODO("requestBody currently only supports JSON body and File body.") + else -> throw UnsupportedOperationException("requestBody currently only supports JSON body and File body.") } protected inline fun responseBody(body: ResponseBody?, mediaType: String? = JsonMediaType): T? { @@ -61,7 +61,7 @@ open class ApiClient(val baseUrl: String) { } return when(mediaType) { JsonMediaType -> Serializer.moshi.adapter(T::class.java).fromJson(bodyContent) - else -> TODO("responseBody currently only supports JSON body.") + else -> throw UnsupportedOperationException("responseBody currently only supports JSON body.") } }