From f81d44bb29348713fe83217f609fec1885fcea5b Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Sat, 18 Nov 2023 07:53:32 +0545 Subject: [PATCH] [PHP-NG] check if json_decode was able to decode response (#17120) --- .../main/resources/php-nextgen/api.mustache | 32 +- .../echo_api/php-nextgen/src/Api/AuthApi.php | 64 +++- .../echo_api/php-nextgen/src/Api/BodyApi.php | 256 +++++++++++++-- .../echo_api/php-nextgen/src/Api/FormApi.php | 64 +++- .../php-nextgen/src/Api/HeaderApi.php | 32 +- .../echo_api/php-nextgen/src/Api/PathApi.php | 32 +- .../echo_api/php-nextgen/src/Api/QueryApi.php | 256 +++++++++++++-- .../src/Api/AnotherFakeApi.php | 32 +- .../OpenAPIClient-php/src/Api/DefaultApi.php | 32 +- .../OpenAPIClient-php/src/Api/FakeApi.php | 304 ++++++++++++++---- .../src/Api/FakeClassnameTags123Api.php | 32 +- .../OpenAPIClient-php/src/Api/PetApi.php | 176 ++++++++-- .../OpenAPIClient-php/src/Api/StoreApi.php | 100 +++++- .../OpenAPIClient-php/src/Api/UserApi.php | 88 +++-- 14 files changed, 1278 insertions(+), 222 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache index 9a0a713963f..fc8819c0ba6 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache @@ -162,7 +162,7 @@ use {{invokerPackage}}\ObjectSerializer; {{/servers}} * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}void{{/returnType}} {{#isDeprecated}} @@ -237,7 +237,7 @@ use {{invokerPackage}}\ObjectSerializer; {{/servers}} * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) {{#isDeprecated}} @@ -311,7 +311,19 @@ use {{invokerPackage}}\ObjectSerializer; } else { $content = (string) $response->getBody(); if ('{{{dataType}}}' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -332,7 +344,19 @@ use {{invokerPackage}}\ObjectSerializer; } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/AuthApi.php b/samples/client/echo_api/php-nextgen/src/Api/AuthApi.php index e79fd9ecf3d..9a00878c8a4 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/AuthApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/AuthApi.php @@ -133,7 +133,7 @@ class AuthApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -152,7 +152,7 @@ class AuthApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -204,7 +204,19 @@ class AuthApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -221,7 +233,19 @@ class AuthApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -410,7 +434,7 @@ class AuthApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -429,7 +453,7 @@ class AuthApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -481,7 +505,19 @@ class AuthApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -498,7 +534,19 @@ class AuthApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php index 6b6ed8287a8..5e3fbb3d8ff 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php @@ -151,7 +151,7 @@ class BodyApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBinaryGif'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \SplFileObject */ @@ -170,7 +170,7 @@ class BodyApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBinaryGif'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \SplFileObject, HTTP status code, HTTP response headers (array of strings) */ @@ -222,7 +222,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('\SplFileObject' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -239,7 +251,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -425,7 +449,7 @@ class BodyApi * @param \SplFileObject|null $body body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyApplicationOctetstreamBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -446,7 +470,7 @@ class BodyApi * @param \SplFileObject|null $body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyApplicationOctetstreamBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -499,7 +523,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -516,7 +552,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -716,7 +764,7 @@ class BodyApi * @param \SplFileObject[] $files files (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataArrayOfBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -737,7 +785,7 @@ class BodyApi * @param \SplFileObject[] $files (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataArrayOfBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -790,7 +838,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -807,7 +867,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1018,7 +1090,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Pet */ @@ -1039,7 +1111,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyAllOfPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) */ @@ -1092,7 +1164,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Pet' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1109,7 +1193,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1309,7 +1405,7 @@ class BodyApi * @param object|null $body Free form object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyFreeFormObjectResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1330,7 +1426,7 @@ class BodyApi * @param object|null $body Free form object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyFreeFormObjectResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1383,7 +1479,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1400,7 +1508,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1600,7 +1720,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Pet */ @@ -1621,7 +1741,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) */ @@ -1674,7 +1794,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Pet' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1691,7 +1823,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1891,7 +2035,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyPetResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1912,7 +2056,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Pet|null $pet Pet object that needs to be added to the store (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyPetResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1965,7 +2109,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1982,7 +2138,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2182,7 +2350,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Tag|null $tag Tag object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyTagResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -2203,7 +2371,7 @@ class BodyApi * @param \OpenAPI\Client\Model\Tag|null $tag Tag object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEchoBodyTagResponseString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -2256,7 +2424,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2273,7 +2453,19 @@ class BodyApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/FormApi.php b/samples/client/echo_api/php-nextgen/src/Api/FormApi.php index d1bf5dd5f3d..7b05d269b34 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/FormApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/FormApi.php @@ -136,7 +136,7 @@ class FormApi * @param string|null $string_form string_form (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -161,7 +161,7 @@ class FormApi * @param string|null $string_form (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -216,7 +216,19 @@ class FormApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -233,7 +245,19 @@ class FormApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -457,7 +481,7 @@ class FormApi * @param string|null $name name (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -488,7 +512,7 @@ class FormApi * @param string|null $name (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -546,7 +570,19 @@ class FormApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -563,7 +599,19 @@ class FormApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php b/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php index e8518ef9f4b..ccd1934afbc 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php @@ -135,7 +135,7 @@ class HeaderApi * @param StringEnumRef|null $enum_ref_string_header enum_ref_string_header (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -164,7 +164,7 @@ class HeaderApi * @param StringEnumRef|null $enum_ref_string_header (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -221,7 +221,19 @@ class HeaderApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -238,7 +250,19 @@ class HeaderApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/PathApi.php b/samples/client/echo_api/php-nextgen/src/Api/PathApi.php index 89abd900432..d9c9352b144 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/PathApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/PathApi.php @@ -134,7 +134,7 @@ class PathApi * @param StringEnumRef $enum_ref_string_path enum_ref_string_path (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -161,7 +161,7 @@ class PathApi * @param StringEnumRef $enum_ref_string_path (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -217,7 +217,19 @@ class PathApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -234,7 +246,19 @@ class PathApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php b/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php index 4f556ae7814..49a6c0f981d 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php @@ -153,7 +153,7 @@ class QueryApi * @param StringEnumRef|null $enum_ref_string_query enum_ref_string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumRefString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -176,7 +176,7 @@ class QueryApi * @param StringEnumRef|null $enum_ref_string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumRefString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -230,7 +230,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -247,7 +259,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -467,7 +491,7 @@ class QueryApi * @param string|null $string_query string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryDatetimeDateString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -492,7 +516,7 @@ class QueryApi * @param string|null $string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryDatetimeDateString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -547,7 +571,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -564,7 +600,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -800,7 +848,7 @@ class QueryApi * @param string|null $string_query string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryIntegerBooleanString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -825,7 +873,7 @@ class QueryApi * @param string|null $string_query (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryIntegerBooleanString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -880,7 +928,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -897,7 +957,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1131,7 +1203,7 @@ class QueryApi * @param Pet|null $query_object query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleDeepObjectExplodeTrueObject'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1152,7 +1224,7 @@ class QueryApi * @param Pet|null $query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleDeepObjectExplodeTrueObject'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1205,7 +1277,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1222,7 +1306,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1424,7 +1520,7 @@ class QueryApi * @param TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter|null $query_object query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleDeepObjectExplodeTrueObjectAllOf'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1445,7 +1541,7 @@ class QueryApi * @param TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter|null $query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleDeepObjectExplodeTrueObjectAllOf'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1498,7 +1594,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1515,7 +1623,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1717,7 +1837,7 @@ class QueryApi * @param TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter|null $query_object query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueArrayString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1738,7 +1858,7 @@ class QueryApi * @param TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter|null $query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueArrayString'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1791,7 +1911,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1808,7 +1940,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2010,7 +2154,7 @@ class QueryApi * @param Pet|null $query_object query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueObject'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -2031,7 +2175,7 @@ class QueryApi * @param Pet|null $query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueObject'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -2084,7 +2228,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2101,7 +2257,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2303,7 +2471,7 @@ class QueryApi * @param DataQuery|null $query_object query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueObjectAllOf'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -2324,7 +2492,7 @@ class QueryApi * @param DataQuery|null $query_object (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryStyleFormExplodeTrueObjectAllOf'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -2377,7 +2545,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2394,7 +2574,19 @@ class QueryApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php index 0bed73dc6ad..5d9011f1eb2 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php @@ -130,7 +130,7 @@ class AnotherFakeApi * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ @@ -151,7 +151,7 @@ class AnotherFakeApi * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ @@ -204,7 +204,19 @@ class AnotherFakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -221,7 +233,19 @@ class AnotherFakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/DefaultApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/DefaultApi.php index da027e2c37f..8d81e22bd13 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/DefaultApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/DefaultApi.php @@ -127,7 +127,7 @@ class DefaultApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\FooGetDefaultResponse */ @@ -144,7 +144,7 @@ class DefaultApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\FooGetDefaultResponse, HTTP status code, HTTP response headers (array of strings) */ @@ -196,7 +196,19 @@ class DefaultApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\FooGetDefaultResponse' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -213,7 +225,19 @@ class DefaultApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } 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 b681d6660c8..8f63741965d 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 @@ -185,7 +185,7 @@ class FakeApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeBigDecimalMap'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\FakeBigDecimalMap200Response */ @@ -202,7 +202,7 @@ class FakeApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeBigDecimalMap'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\FakeBigDecimalMap200Response, HTTP status code, HTTP response headers (array of strings) */ @@ -254,7 +254,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\FakeBigDecimalMap200Response' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -271,7 +283,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -452,7 +476,7 @@ class FakeApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\HealthCheckResult */ @@ -471,7 +495,7 @@ class FakeApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\HealthCheckResult, HTTP status code, HTTP response headers (array of strings) */ @@ -523,7 +547,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\HealthCheckResult' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -540,7 +576,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -728,7 +776,7 @@ class FakeApi * @param string|null $header_1 header parameter (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -752,7 +800,7 @@ class FakeApi * @param string|null $header_1 header parameter (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -1002,7 +1050,7 @@ class FakeApi * @param bool|null $body Input boolean as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return bool */ @@ -1021,7 +1069,7 @@ class FakeApi * @param bool|null $body Input boolean as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of bool, HTTP status code, HTTP response headers (array of strings) */ @@ -1074,7 +1122,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('bool' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1091,7 +1151,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1285,7 +1357,7 @@ class FakeApi * @param \OpenAPI\Client\Model\OuterComposite|null $outer_composite Input composite as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\OuterComposite */ @@ -1304,7 +1376,7 @@ class FakeApi * @param \OpenAPI\Client\Model\OuterComposite|null $outer_composite Input composite as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings) */ @@ -1357,7 +1429,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\OuterComposite' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1374,7 +1458,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1568,7 +1664,7 @@ class FakeApi * @param float|null $body Input number as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return float */ @@ -1587,7 +1683,7 @@ class FakeApi * @param float|null $body Input number as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of float, HTTP status code, HTTP response headers (array of strings) */ @@ -1640,7 +1736,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('float' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1657,7 +1765,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1851,7 +1971,7 @@ class FakeApi * @param string|null $body Input string as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1870,7 +1990,7 @@ class FakeApi * @param string|null $body Input string as post body (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1923,7 +2043,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1940,7 +2072,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2134,7 +2278,7 @@ class FakeApi * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\OuterObjectWithEnumProperty */ @@ -2153,7 +2297,7 @@ class FakeApi * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\OuterObjectWithEnumProperty, HTTP status code, HTTP response headers (array of strings) */ @@ -2206,7 +2350,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\OuterObjectWithEnumProperty' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2223,7 +2379,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2423,7 +2591,7 @@ class FakeApi * @param \SplFileObject $body image to upload (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -2441,7 +2609,7 @@ class FakeApi * @param \SplFileObject $body image to upload (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -2658,7 +2826,7 @@ class FakeApi * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class file_schema_test_class (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -2676,7 +2844,7 @@ class FakeApi * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -2894,7 +3062,7 @@ class FakeApi * @param \OpenAPI\Client\Model\User $user user (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -2914,7 +3082,7 @@ class FakeApi * @param \OpenAPI\Client\Model\User $user (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -3156,7 +3324,7 @@ class FakeApi * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ @@ -3177,7 +3345,7 @@ class FakeApi * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ @@ -3230,7 +3398,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -3247,7 +3427,19 @@ class FakeApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -3466,7 +3658,7 @@ class FakeApi * @param string|null $callback None (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -3512,7 +3704,7 @@ class FakeApi * @param string|null $callback None (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -3965,7 +4157,7 @@ class FakeApi * @param string|null $enum_form_string Form parameter enum test (string) (optional, default to '-efg') * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -4001,7 +4193,7 @@ class FakeApi * @param string|null $enum_form_string Form parameter enum test (string) (optional, default to '-efg') * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -4346,7 +4538,7 @@ class FakeApi * @param int|null $int64_group Integer in group parameters (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -4372,7 +4564,7 @@ class FakeApi * @param int|null $int64_group Integer in group parameters (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -4678,7 +4870,7 @@ class FakeApi * @param array $request_body request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -4698,7 +4890,7 @@ class FakeApi * @param array $request_body request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -4921,7 +5113,7 @@ class FakeApi * @param \OpenAPI\Client\Model\TestInlineFreeformAdditionalPropertiesRequest $test_inline_freeform_additional_properties_request request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineFreeformAdditionalProperties'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -4941,7 +5133,7 @@ class FakeApi * @param \OpenAPI\Client\Model\TestInlineFreeformAdditionalPropertiesRequest $test_inline_freeform_additional_properties_request request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineFreeformAdditionalProperties'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -5165,7 +5357,7 @@ class FakeApi * @param string $param2 field2 (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -5187,7 +5379,7 @@ class FakeApi * @param string $param2 field2 (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -5425,7 +5617,7 @@ class FakeApi * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -5445,7 +5637,7 @@ class FakeApi * @param \OpenAPI\Client\Model\ChildWithNullable $child_with_nullable request body (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testNullable'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -5672,7 +5864,7 @@ class FakeApi * @param array|null $language language (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -5702,7 +5894,7 @@ class FakeApi * @param array|null $language (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php index 776c4747cb0..94822327c19 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php @@ -130,7 +130,7 @@ class FakeClassnameTags123Api * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ @@ -151,7 +151,7 @@ class FakeClassnameTags123Api * @param \OpenAPI\Client\Model\Client $client client model (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ @@ -204,7 +204,19 @@ class FakeClassnameTags123Api } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -221,7 +233,19 @@ class FakeClassnameTags123Api } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php index 193bc94d311..16aafd97e7a 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php @@ -174,7 +174,7 @@ class PetApi * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -214,7 +214,7 @@ class PetApi * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -556,7 +556,7 @@ class PetApi * @param string|null $api_key api_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -578,7 +578,7 @@ class PetApi * @param string|null $api_key (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -818,7 +818,7 @@ class PetApi * @param string[] $status Status values that need to be considered for filter (required) (deprecated) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Pet[] */ @@ -839,7 +839,7 @@ class PetApi * @param string[] $status Status values that need to be considered for filter (required) (deprecated) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) */ @@ -892,7 +892,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Pet[]' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -909,7 +921,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1121,7 +1145,7 @@ class PetApi * @param string[] $tags Tags to filter by (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Pet[] * @deprecated @@ -1143,7 +1167,7 @@ class PetApi * @param string[] $tags Tags to filter by (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @deprecated @@ -1197,7 +1221,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Pet[]' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1214,7 +1250,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1429,7 +1477,7 @@ class PetApi * @param int $pet_id ID of pet to return (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Pet */ @@ -1450,7 +1498,7 @@ class PetApi * @param int $pet_id ID of pet to return (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) */ @@ -1503,7 +1551,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Pet' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1520,7 +1580,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1750,7 +1822,7 @@ class PetApi * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -1790,7 +1862,7 @@ class PetApi * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -2133,7 +2205,7 @@ class PetApi * @param string|null $status Updated status of the pet (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -2157,7 +2229,7 @@ class PetApi * @param string|null $status Updated status of the pet (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -2411,7 +2483,7 @@ class PetApi * @param \SplFileObject|null $file file to upload (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\ApiResponse */ @@ -2436,7 +2508,7 @@ class PetApi * @param \SplFileObject|null $file file to upload (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) */ @@ -2491,7 +2563,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2508,7 +2592,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2751,7 +2847,7 @@ class PetApi * @param string|null $additional_metadata Additional data to pass to server (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\ApiResponse */ @@ -2776,7 +2872,7 @@ class PetApi * @param string|null $additional_metadata Additional data to pass to server (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) */ @@ -2831,7 +2927,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -2848,7 +2956,19 @@ class PetApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php index b5ee394b771..b2ec167a667 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php @@ -139,7 +139,7 @@ class StoreApi * @param string $order_id ID of the order that needs to be deleted (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -159,7 +159,7 @@ class StoreApi * @param string $order_id ID of the order that needs to be deleted (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -382,7 +382,7 @@ class StoreApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array */ @@ -401,7 +401,7 @@ class StoreApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of array, HTTP status code, HTTP response headers (array of strings) */ @@ -453,7 +453,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ('array' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -470,7 +482,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -661,7 +685,7 @@ class StoreApi * @param int $order_id ID of pet that needs to be fetched (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Order */ @@ -682,7 +706,7 @@ class StoreApi * @param int $order_id ID of pet that needs to be fetched (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ @@ -735,7 +759,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Order' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -752,7 +788,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -965,7 +1013,7 @@ class StoreApi * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\Order */ @@ -986,7 +1034,7 @@ class StoreApi * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ @@ -1039,7 +1087,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\Order' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1056,7 +1116,19 @@ class StoreApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php index 3acc81701e3..630fbf53647 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php @@ -151,7 +151,7 @@ class UserApi * @param \OpenAPI\Client\Model\User $user Created user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -171,7 +171,7 @@ class UserApi * @param \OpenAPI\Client\Model\User $user Created user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -394,7 +394,7 @@ class UserApi * @param \OpenAPI\Client\Model\User[] $user List of user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -414,7 +414,7 @@ class UserApi * @param \OpenAPI\Client\Model\User[] $user List of user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -637,7 +637,7 @@ class UserApi * @param \OpenAPI\Client\Model\User[] $user List of user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -657,7 +657,7 @@ class UserApi * @param \OpenAPI\Client\Model\User[] $user List of user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -880,7 +880,7 @@ class UserApi * @param string $username The name that needs to be deleted (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -900,7 +900,7 @@ class UserApi * @param string $username The name that needs to be deleted (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -1124,7 +1124,7 @@ class UserApi * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return \OpenAPI\Client\Model\User */ @@ -1145,7 +1145,7 @@ class UserApi * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of \OpenAPI\Client\Model\User, HTTP status code, HTTP response headers (array of strings) */ @@ -1198,7 +1198,19 @@ class UserApi } else { $content = (string) $response->getBody(); if ('\OpenAPI\Client\Model\User' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1215,7 +1227,19 @@ class UserApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1423,7 +1447,7 @@ class UserApi * @param string $password The password for login in clear text (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return string */ @@ -1446,7 +1470,7 @@ class UserApi * @param string $password The password for login in clear text (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ @@ -1500,7 +1524,19 @@ class UserApi } else { $content = (string) $response->getBody(); if ('string' !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1517,7 +1553,19 @@ class UserApi } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { - $content = json_decode($content); + try { + $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $exception) { + throw new ApiException( + sprintf( + 'Error JSON decoding server response (%s)', + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $content + ); + } } } @@ -1746,7 +1794,7 @@ class UserApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -1764,7 +1812,7 @@ class UserApi * * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ @@ -1967,7 +2015,7 @@ class UserApi * @param \OpenAPI\Client\Model\User $user Updated user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return void */ @@ -1989,7 +2037,7 @@ class UserApi * @param \OpenAPI\Client\Model\User $user Updated user object (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * - * @throws ApiException on non-2xx response + * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */