From fc3745866875ff57a1b73122c5d85033f1a813b6 Mon Sep 17 00:00:00 2001 From: Roel Wuytens Date: Sun, 6 Oct 2024 10:25:36 +0200 Subject: [PATCH 1/3] Allow Unit response --- .../jvm-okhttp/infrastructure/ApiClient.kt.mustache | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- .../org/openapitools/client/infrastructure/ApiClient.kt | 7 +++++-- 21 files changed, 105 insertions(+), 42 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache index 8aabf649f883..c7580755b966 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache @@ -167,8 +167,11 @@ import com.squareup.moshi.adapter val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 2e3b0b4e0f76..8de04930d62d 100644 --- a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index e6a9896593e8..7cf0c6635a1f 100644 --- a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -124,8 +124,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index aa1ce67cfcb7..02a2a5b6ed79 100644 --- a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -126,8 +126,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index e63708077704..3115edc9d63f 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,8 +127,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c6d72a4d175f..1459f80d4133 100644 --- a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c6d72a4d175f..1459f80d4133 100644 --- a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c6d72a4d175f..1459f80d4133 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index bddc06185e07..7e288ce70fc5 100644 --- a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1a8f49006069..21516fdd5cc1 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ internal open class ApiClient(val baseUrl: String, val client: Call.Factory = de val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c6d72a4d175f..1459f80d4133 100644 --- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") 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 c6d72a4d175f..1459f80d4133 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 @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") 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 c3d43ff809c4..70db344a8fb0 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 @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") diff --git a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index f381dee978ea..10f89e504a58 100644 --- a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") 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 c6d72a4d175f..1459f80d4133 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 @@ -125,8 +125,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie val body = response.body if(body == null) { return null - } - if (T::class.java == File::class.java) { + } else if (T::class.java == Unit::class.java) { + // No need to parse the body when we're not interested in the body + // Or when other content-type + return null + } else if (T::class.java == File::class.java) { // return tempFile val contentDisposition = response.header("Content-Disposition") From 942c50af6e405e587cd44f559baaa3b8ac38de12 Mon Sep 17 00:00:00 2001 From: Roel Wuytens Date: Mon, 7 Oct 2024 11:48:23 +0200 Subject: [PATCH 2/3] Updating samples --- .../OpenAPIClient-php/src/Api/FakeApi.php | 25 ++++++++++--------- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 25 ++++++++++--------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php index fff2b1a29e82..15ff079f647e 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php @@ -549,18 +549,6 @@ public function fakeEnumEndpointWithHttpInfo( $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } switch($statusCode) { case 200: @@ -592,6 +580,19 @@ public function fakeEnumEndpointWithHttpInfo( ]; } + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + $returnType = '\OpenAPI\Client\Model\EnumClass'; if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) { $content = $response->getBody(); //stream goes to serializer diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 1037fe0354d3..52054dfdb12b 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -529,18 +529,6 @@ public function fakeEnumEndpointWithHttpInfo($enum_class, $enum_class_array, $en $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } switch($statusCode) { case 200: @@ -572,6 +560,19 @@ public function fakeEnumEndpointWithHttpInfo($enum_class, $enum_class_array, $en ]; } + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + $returnType = '\OpenAPI\Client\Model\EnumClass'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer From ed798328cd627936bf9d381b95b26399042490e6 Mon Sep 17 00:00:00 2001 From: Roel Wuytens Date: Mon, 7 Oct 2024 12:59:45 +0200 Subject: [PATCH 3/3] Improve comment for Unit shortcut --- .../libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- .../kotlin/org/openapitools/client/infrastructure/ApiClient.kt | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache index c7580755b966..606b70f1fa8a 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-okhttp/infrastructure/ApiClient.kt.mustache @@ -169,7 +169,7 @@ import com.squareup.moshi.adapter return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/others/kotlin-jvm-okhttp-parameter-tests/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-allOff-discriminator/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-array-simple-string-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-default-values-jvm-okhttp4/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 8de04930d62d..18243f43238e 100644 --- a/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-gson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -126,7 +126,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7cf0c6635a1f..1d0b545aa6b2 100644 --- a/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jackson/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -126,7 +126,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 02a2a5b6ed79..fcc902c1d558 100644 --- a/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-json-request-string/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -128,7 +128,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 3115edc9d63f..c419e4b0de2d 100644 --- a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -129,7 +129,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1459f80d4133..74b362833cc9 100644 --- a/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-kotlinx-datetime/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1459f80d4133..74b362833cc9 100644 --- a/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-modelMutable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1459f80d4133..74b362833cc9 100644 --- a/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-moshi-codegen/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 7e288ce70fc5..2c84a6bf23ac 100644 --- a/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-name-parameter-mappings/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 21516fdd5cc1..96cab6d6d5d5 100644 --- a/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nonpublic/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ internal open class ApiClient(val baseUrl: String, val client: Call.Factory = de return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 1459f80d4133..74b362833cc9 100644 --- a/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-nullable/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile 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 1459f80d4133..74b362833cc9 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 @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile 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 70db344a8fb0..fe3124d35eb0 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 @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile diff --git a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index 10f89e504a58..934673c9da9f 100644 --- a/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-uppercase-enum/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile 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 1459f80d4133..74b362833cc9 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 @@ -127,7 +127,7 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie return null } else if (T::class.java == Unit::class.java) { // No need to parse the body when we're not interested in the body - // Or when other content-type + // Useful when API is returning other Content-Type return null } else if (T::class.java == File::class.java) { // return tempFile