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