forked from loafle/openapi-generator-original
[PHP] - Add range HTTP code support (#20992)
* [PHP] - Add range HTTP code support * Adding response body to 200 * Fix diff; update php-nextgen sample * Working on unit tests * Removes dangling files * Finalize tests * Remove dangling files * Add tests for no response body exception
This commit is contained in:
@@ -36,6 +36,8 @@ use GuzzleHttp\Psr7\MultipartStream;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use OpenAPI\Client\ApiException;
|
||||
use OpenAPI\Client\Configuration;
|
||||
use OpenAPI\Client\HeaderSelector;
|
||||
@@ -208,36 +210,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('\SplFileObject', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('\SplFileObject' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\SplFileObject', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'\SplFileObject',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -252,34 +233,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = '\SplFileObject';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'\SplFileObject',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -289,8 +247,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -510,36 +469,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -554,34 +492,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -591,8 +506,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -826,36 +742,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -870,34 +765,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -907,8 +779,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1155,36 +1028,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -1199,34 +1051,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -1236,8 +1065,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1478,36 +1308,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('\OpenAPI\Client\Model\Pet', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('\OpenAPI\Client\Model\Pet' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\Pet',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -1522,34 +1331,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\Pet';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\Pet',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -1559,8 +1345,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -1794,36 +1581,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -1838,34 +1604,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -1875,8 +1618,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2110,36 +1854,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('\OpenAPI\Client\Model\Pet', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('\OpenAPI\Client\Model\Pet' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\Pet',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -2154,34 +1877,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\Pet';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\Pet',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -2191,8 +1891,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2426,36 +2127,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -2470,34 +2150,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -2507,8 +2164,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -2742,36 +2400,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('\OpenAPI\Client\Model\StringEnumRef', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('\OpenAPI\Client\Model\StringEnumRef' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\StringEnumRef', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\StringEnumRef',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -2786,34 +2423,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\StringEnumRef';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'\OpenAPI\Client\Model\StringEnumRef',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -2823,8 +2437,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -3058,36 +2673,15 @@ class BodyApi
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ('string' !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, 'string', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($statusCode < 200 || $statusCode > 299) {
|
||||
throw new ApiException(
|
||||
@@ -3102,34 +2696,11 @@ class BodyApi
|
||||
);
|
||||
}
|
||||
|
||||
$returnType = 'string';
|
||||
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($returnType !== 'string') {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
return $this->handleResponseWithDataType(
|
||||
'string',
|
||||
$request,
|
||||
$response,
|
||||
);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
@@ -3139,8 +2710,9 @@ class BodyApi
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -3330,4 +2902,47 @@ class BodyApi
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function handleResponseWithDataType(
|
||||
string $dataType,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
): array {
|
||||
if (in_array($dataType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
if ($dataType !== 'string') {
|
||||
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()
|
||||
),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders(),
|
||||
$content
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $dataType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
}
|
||||
|
||||
private function responseWithinRangeCode(
|
||||
string $rangeCode,
|
||||
int $statusCode,
|
||||
): bool {
|
||||
$left = (int) ($rangeCode[0].'00');
|
||||
$right = (int) ($rangeCode[0].'99');
|
||||
|
||||
return $statusCode >= $left && $statusCode <= $right;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user