forked from loafle/openapi-generator-original
[PHP-NG] check if json_decode was able to decode response (#17120)
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user