forked from loafle/openapi-generator-original
Merge pull request #485 from wing328/fix_php_string_response
minor bug fixes and enhancement to Swagger.php
This commit is contained in:
commit
156ec2a2dd
@ -129,11 +129,14 @@ class APIClient {
|
|||||||
if ($response_info['http_code'] == 0) {
|
if ($response_info['http_code'] == 0) {
|
||||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
throw new APIClientException("TIMEOUT: api call to " . $url .
|
||||||
" took more than 5s to return", 0, $response_info, $response);
|
" took more than 5s to return", 0, $response_info, $response);
|
||||||
} else if ($response_info['http_code'] == 200) {
|
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||||
$data = json_decode($response);
|
$data = json_decode($response);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $response;
|
||||||
|
}
|
||||||
} else if ($response_info['http_code'] == 401) {
|
} else if ($response_info['http_code'] == 401) {
|
||||||
throw new APIClientException("Unauthorized API request to " . $url .
|
throw new APIClientException("Unauthorized API request to " . $url .
|
||||||
": " . json_decode($response)->message, 0, $response_info, $response);
|
": " . serialize($response), 0, $response_info, $response);
|
||||||
} else if ($response_info['http_code'] == 404) {
|
} else if ($response_info['http_code'] == 404) {
|
||||||
$data = null;
|
$data = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,11 +129,14 @@ class APIClient {
|
|||||||
if ($response_info['http_code'] == 0) {
|
if ($response_info['http_code'] == 0) {
|
||||||
throw new APIClientException("TIMEOUT: api call to " . $url .
|
throw new APIClientException("TIMEOUT: api call to " . $url .
|
||||||
" took more than 5s to return", 0, $response_info, $response);
|
" took more than 5s to return", 0, $response_info, $response);
|
||||||
} else if ($response_info['http_code'] == 200) {
|
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
|
||||||
$data = json_decode($response);
|
$data = json_decode($response);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $response;
|
||||||
|
}
|
||||||
} else if ($response_info['http_code'] == 401) {
|
} else if ($response_info['http_code'] == 401) {
|
||||||
throw new APIClientException("Unauthorized API request to " . $url .
|
throw new APIClientException("Unauthorized API request to " . $url .
|
||||||
": " . json_decode($response)->message, 0, $response_info, $response);
|
": " . serialize($response), 0, $response_info, $response);
|
||||||
} else if ($response_info['http_code'] == 404) {
|
} else if ($response_info['http_code'] == 404) {
|
||||||
$data = null;
|
$data = null;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user