[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:
Juan Treminio 2025-04-06 11:50:58 -05:00 committed by GitHub
parent 5f41acfe79
commit 6b13ad522f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 10873 additions and 6261 deletions

View File

@ -26,6 +26,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 {{invokerPackage}}\ApiException;
use {{invokerPackage}}\Configuration;
use {{invokerPackage}}\HeaderSelector;
@ -289,42 +291,28 @@ use {{invokerPackage}}\ObjectSerializer;
{{#returnType}}
{{#responses}}
{{#-first}}
switch($statusCode) {
{{/-first}}
{{#dataType}}
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '{{{dataType}}}', []),
$response->getStatusCode(),
$response->getHeaders()
];{{/isRange}}
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);{{/isRange}}
{{/dataType}}
{{#-last}}
}
{{/-last}}
{{/responses}}
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}
if ($this->responseWithinRangeCode('{{code}}', $statusCode)) {
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -339,39 +327,16 @@ use {{invokerPackage}}\ObjectSerializer;
);
}
$returnType = '{{{returnType}}}';
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(
'{{{returnType}}}',
$request,
$response,
);
{{/returnType}}
{{^returnType}}
return [null, $statusCode, $response->getHeaders()];
{{/returnType}}
} catch (ApiException $e) {
switch ($e->getCode()) {
{{#responses}}
@ -383,10 +348,20 @@ use {{invokerPackage}}\ObjectSerializer;
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;{{/isRange}}
throw $e;{{/isRange}}
{{/dataType}}
{{/responses}}
}
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}
if ($this->responseWithinRangeCode('{{code}}', $e->getCode())) {
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'{{{dataType}}}',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
throw $e;
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
throw $e;
}
}
@ -938,5 +913,48 @@ use {{invokerPackage}}\ObjectSerializer;
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;
}
}
{{/operations}}

View File

@ -25,6 +25,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use {{invokerPackage}}\ApiException;
use {{invokerPackage}}\Configuration;
use {{invokerPackage}}\HeaderSelector;
@ -262,38 +264,25 @@ use {{invokerPackage}}\ObjectSerializer;
{{/-first}}
{{#dataType}}
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
if ('{{{dataType}}}' === '\SplFileObject') {
$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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '{{{dataType}}}', []),
$response->getStatusCode(),
$response->getHeaders()
];{{/isRange}}
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);{{/isRange}}
{{/dataType}}
{{#-last}}
}
{{/-last}}
{{/responses}}
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}if ($this->responseWithinRangeCode('{{code}}', $statusCode)) {
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -307,39 +296,16 @@ use {{invokerPackage}}\ObjectSerializer;
);
}
$returnType = '{{{returnType}}}';
if ($returnType === '\SplFileObject') {
$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(
'{{{returnType}}}',
$request,
$response,
);
{{/returnType}}
{{^returnType}}
return [null, $statusCode, $response->getHeaders()];
{{/returnType}}
} catch (ApiException $e) {
switch ($e->getCode()) {
{{#responses}}
@ -351,10 +317,21 @@ use {{invokerPackage}}\ObjectSerializer;
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;{{/isRange}}
throw $e;{{/isRange}}
{{/dataType}}
{{/responses}}
}
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}
if ($this->responseWithinRangeCode('{{code}}', $e->getCode())) {
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'{{{dataType}}}',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
throw $e;
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
throw $e;
}
}
@ -859,5 +836,48 @@ use {{invokerPackage}}\ObjectSerializer;
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}
{{/operations}}

View File

@ -39,6 +39,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -263,6 +264,7 @@ use function sprintf;
}
$statusCode = $response->getStatusCode();
{{#returnType}}
{{#responses}}
{{#-first}}
@ -270,57 +272,75 @@ use function sprintf;
switch($statusCode) {
{{/-first}}
{{#dataType}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
if ('{{{dataType}}}' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '{{{dataType}}}', []),
$response->getStatusCode(),
$response->getHeaders()
];
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);{{/isRange}}
{{/dataType}}
{{#-last}}
}
{{/-last}}
{{/responses}}
$returnType = '{{{returnType}}}';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}if ($this->responseWithinRangeCode('{{code}}', $statusCode)) {
return $this->handleResponseWithDataType(
'{{{dataType}}}',
$request,
$response,
);
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'{{{returnType}}}',
$request,
$response,
);
{{/returnType}}
{{^returnType}}
return [null, $statusCode, $response->getHeaders()];
{{/returnType}}
} catch (ApiException $e) {
switch ($e->getCode()) {
{{#responses}}
{{#dataType}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'{{{dataType}}}',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;{{/isRange}}
{{/dataType}}
{{/responses}}
}
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}
if ($this->responseWithinRangeCode('{{code}}', $e->getCode())) {
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'{{{dataType}}}',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
throw $e;
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
throw $e;
}
}
@ -769,5 +789,48 @@ use function sprintf;
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}
{{/operations}}

View File

@ -1339,6 +1339,111 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/EnumClass'
/fake/with_400_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 response http code with dataType
operationId: fake-with_400_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_4xx_range_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400-499 range response http code with dataType
operationId: fake-with_4xx_range_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'4xx':
description: Range of HTTP code 400-499
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_4xx_range_response_no_4xx_datatype/endpoint:
post:
tags:
- fake
summary: test endpoint with 400-499 range response http code without dataType
operationId: fake-with_4xx_range_response_no_4xx_datatype-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'4xx':
description: Range of HTTP code 400-499
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_400_and_4xx_range_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 and 400-499 range response http code with dataType
operationId: fake-with_400_and_4xx_range_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'4xx':
description: Range of HTTP code 400-499
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 and 400-499 range response http code without dataType
operationId: fake-with_400_and_4xx_range_response_no_4xx_datatype-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
'4xx':
description: Range of HTTP code 400-499
requestBody:
$ref: '#/components/requestBodies/Pet'
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
@ -2118,3 +2223,10 @@ components:
- The word one
- The digit two
- The digit three prefixed by a space
ErrorResponse:
type: object
properties:
response_code:
type: integer
error:
type: string

View File

@ -1394,6 +1394,111 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/EnumClass'
/fake/with_400_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 response http code with dataType
operationId: fake-with_400_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_4xx_range_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400-499 range response http code with dataType
operationId: fake-with_4xx_range_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'4xx':
description: Range of HTTP code 400-499
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_4xx_range_response_no_4xx_datatype/endpoint:
post:
tags:
- fake
summary: test endpoint with 400-499 range response http code without dataType
operationId: fake-with_4xx_range_response_no_4xx_datatype-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'4xx':
description: Range of HTTP code 400-499
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_400_and_4xx_range_response/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 and 400-499 range response http code with dataType
operationId: fake-with_400_and_4xx_range_response-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'4xx':
description: Range of HTTP code 400-499
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
requestBody:
$ref: '#/components/requestBodies/Pet'
/fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint:
post:
tags:
- fake
summary: test endpoint with 400 and 400-499 range response http code without dataType
operationId: fake-with_400_and_4xx_range_response_no_4xx_datatype-endpoint
responses:
200:
description: Valid status value
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
'4xx':
description: Range of HTTP code 400-499
requestBody:
$ref: '#/components/requestBodies/Pet'
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
@ -2206,3 +2311,10 @@ components:
- The word one
- The digit two
- The digit three prefixed by a space
ErrorResponse:
type: object
properties:
response_code:
type: integer
error:
type: string

View File

@ -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;
@ -184,36 +186,15 @@ class AuthApi
$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(
@ -228,34 +209,11 @@ class AuthApi
);
}
$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:
@ -265,8 +223,9 @@ class AuthApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -486,36 +445,15 @@ class AuthApi
$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(
@ -530,34 +468,11 @@ class AuthApi
);
}
$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:
@ -567,8 +482,9 @@ class AuthApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -748,4 +664,47 @@ class AuthApi
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;
}
}

View File

@ -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('\Psr\Http\Message\StreamInterface', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Psr\Http\Message\StreamInterface' !== '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, '\Psr\Http\Message\StreamInterface', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\Psr\Http\Message\StreamInterface',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -252,34 +233,11 @@ class BodyApi
);
}
$returnType = '\Psr\Http\Message\StreamInterface';
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(
'\Psr\Http\Message\StreamInterface',
$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;
}
}

View File

@ -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;
@ -199,36 +201,15 @@ class FormApi
$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(
@ -243,34 +224,11 @@ class FormApi
);
}
$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:
@ -280,8 +238,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -534,36 +493,15 @@ class FormApi
$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(
@ -578,34 +516,11 @@ class FormApi
);
}
$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:
@ -615,8 +530,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -873,36 +789,15 @@ class FormApi
$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(
@ -917,34 +812,11 @@ class FormApi
);
}
$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:
@ -954,8 +826,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1197,4 +1070,47 @@ class FormApi
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;
}
}

View File

@ -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;
@ -201,36 +203,15 @@ class HeaderApi
$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(
@ -245,34 +226,11 @@ class HeaderApi
);
}
$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:
@ -282,8 +240,9 @@ class HeaderApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -514,4 +473,47 @@ class HeaderApi
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;
}
}

View File

@ -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;
@ -197,36 +199,15 @@ class PathApi
$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(
@ -241,34 +222,11 @@ class PathApi
);
}
$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:
@ -278,8 +236,9 @@ class PathApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -539,4 +498,47 @@ class PathApi
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;
}
}

View File

@ -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;
@ -216,36 +218,15 @@ class QueryApi
$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(
@ -260,34 +241,11 @@ class QueryApi
);
}
$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:
@ -297,8 +255,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -558,36 +517,15 @@ class QueryApi
$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(
@ -602,34 +540,11 @@ class QueryApi
);
}
$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:
@ -639,8 +554,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -916,36 +832,15 @@ class QueryApi
$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(
@ -960,34 +855,11 @@ class QueryApi
);
}
$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:
@ -997,8 +869,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1266,36 +1139,15 @@ class QueryApi
$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(
@ -1310,34 +1162,11 @@ class QueryApi
);
}
$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:
@ -1347,8 +1176,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1584,36 +1414,15 @@ class QueryApi
$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(
@ -1628,34 +1437,11 @@ class QueryApi
);
}
$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:
@ -1665,8 +1451,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1902,36 +1689,15 @@ class QueryApi
$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(
@ -1946,34 +1712,11 @@ class QueryApi
);
}
$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:
@ -1983,8 +1726,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2220,36 +1964,15 @@ class QueryApi
$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(
@ -2264,34 +1987,11 @@ class QueryApi
);
}
$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:
@ -2301,8 +2001,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2538,36 +2239,15 @@ class QueryApi
$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(
@ -2582,34 +2262,11 @@ class QueryApi
);
}
$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:
@ -2619,8 +2276,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2856,36 +2514,15 @@ class QueryApi
$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(
@ -2900,34 +2537,11 @@ class QueryApi
);
}
$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:
@ -2937,8 +2551,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3174,36 +2789,15 @@ class QueryApi
$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(
@ -3218,34 +2812,11 @@ class QueryApi
);
}
$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:
@ -3255,8 +2826,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3448,4 +3020,47 @@ class QueryApi
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;
}
}

View File

@ -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;
@ -184,36 +186,15 @@ class AuthApi
$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(
@ -228,34 +209,11 @@ class AuthApi
);
}
$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:
@ -265,8 +223,9 @@ class AuthApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -486,36 +445,15 @@ class AuthApi
$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(
@ -530,34 +468,11 @@ class AuthApi
);
}
$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:
@ -567,8 +482,9 @@ class AuthApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -748,4 +664,47 @@ class AuthApi
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;
}
}

View File

@ -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;
}
}

View File

@ -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;
@ -199,36 +201,15 @@ class FormApi
$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(
@ -243,34 +224,11 @@ class FormApi
);
}
$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:
@ -280,8 +238,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -534,36 +493,15 @@ class FormApi
$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(
@ -578,34 +516,11 @@ class FormApi
);
}
$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:
@ -615,8 +530,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -873,36 +789,15 @@ class FormApi
$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(
@ -917,34 +812,11 @@ class FormApi
);
}
$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:
@ -954,8 +826,9 @@ class FormApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1197,4 +1070,47 @@ class FormApi
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;
}
}

View File

@ -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;
@ -201,36 +203,15 @@ class HeaderApi
$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(
@ -245,34 +226,11 @@ class HeaderApi
);
}
$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:
@ -282,8 +240,9 @@ class HeaderApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -514,4 +473,47 @@ class HeaderApi
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;
}
}

View File

@ -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;
@ -197,36 +199,15 @@ class PathApi
$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(
@ -241,34 +222,11 @@ class PathApi
);
}
$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:
@ -278,8 +236,9 @@ class PathApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -539,4 +498,47 @@ class PathApi
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;
}
}

View File

@ -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;
@ -216,36 +218,15 @@ class QueryApi
$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(
@ -260,34 +241,11 @@ class QueryApi
);
}
$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:
@ -297,8 +255,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -558,36 +517,15 @@ class QueryApi
$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(
@ -602,34 +540,11 @@ class QueryApi
);
}
$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:
@ -639,8 +554,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -916,36 +832,15 @@ class QueryApi
$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(
@ -960,34 +855,11 @@ class QueryApi
);
}
$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:
@ -997,8 +869,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1266,36 +1139,15 @@ class QueryApi
$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(
@ -1310,34 +1162,11 @@ class QueryApi
);
}
$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:
@ -1347,8 +1176,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1584,36 +1414,15 @@ class QueryApi
$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(
@ -1628,34 +1437,11 @@ class QueryApi
);
}
$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:
@ -1665,8 +1451,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1902,36 +1689,15 @@ class QueryApi
$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(
@ -1946,34 +1712,11 @@ class QueryApi
);
}
$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:
@ -1983,8 +1726,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2220,36 +1964,15 @@ class QueryApi
$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(
@ -2264,34 +1987,11 @@ class QueryApi
);
}
$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:
@ -2301,8 +2001,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2538,36 +2239,15 @@ class QueryApi
$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(
@ -2582,34 +2262,11 @@ class QueryApi
);
}
$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:
@ -2619,8 +2276,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2856,36 +2514,15 @@ class QueryApi
$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(
@ -2900,34 +2537,11 @@ class QueryApi
);
}
$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:
@ -2937,8 +2551,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3174,36 +2789,15 @@ class QueryApi
$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(
@ -3218,34 +2812,11 @@ class QueryApi
);
}
$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:
@ -3255,8 +2826,9 @@ class QueryApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3448,4 +3020,47 @@ class QueryApi
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;
}
}

View File

@ -30,6 +30,7 @@ docs/Model/EnumArrays.md
docs/Model/EnumClass.md
docs/Model/EnumTest.md
docs/Model/EnumWithNameAndDescription.md
docs/Model/ErrorResponse.md
docs/Model/FakeBigDecimalMap200Response.md
docs/Model/File.md
docs/Model/FileSchemaTestClass.md
@ -93,6 +94,7 @@ src/Model/EnumArrays.php
src/Model/EnumClass.php
src/Model/EnumTest.php
src/Model/EnumWithNameAndDescription.php
src/Model/ErrorResponse.php
src/Model/FakeBigDecimalMap200Response.php
src/Model/File.php
src/Model/FileSchemaTestClass.php

View File

@ -82,6 +82,11 @@ Class | Method | HTTP request | Description
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
*FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/Api/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
*FakeApi* | [**fakeWith400And4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseendpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType
*FakeApi* | [**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType
*FakeApi* | [**fakeWith400ResponseEndpoint**](docs/Api/FakeApi.md#fakewith400responseendpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseendpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType
*FakeApi* | [**testAdditionalPropertiesReference**](docs/Api/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties
*FakeApi* | [**testBodyWithBinary**](docs/Api/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
*FakeApi* | [**testBodyWithFileSchema**](docs/Api/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
@ -140,6 +145,7 @@ Class | Method | HTTP request | Description
- [EnumClass](docs/Model/EnumClass.md)
- [EnumTest](docs/Model/EnumTest.md)
- [EnumWithNameAndDescription](docs/Model/EnumWithNameAndDescription.md)
- [ErrorResponse](docs/Model/ErrorResponse.md)
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
- [File](docs/Model/File.md)
- [FileSchemaTestClass](docs/Model/FileSchemaTestClass.md)

View File

@ -13,6 +13,11 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati
| [**fakeOuterNumberSerialize()**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | |
| [**fakeOuterStringSerialize()**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | |
| [**fakePropertyEnumIntegerSerialize()**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | |
| [**fakeWith400And4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseEndpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType |
| [**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType |
| [**fakeWith400ResponseEndpoint()**](FakeApi.md#fakeWith400ResponseEndpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType |
| [**fakeWith4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseEndpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType |
| [**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType |
| [**testAdditionalPropertiesReference()**](FakeApi.md#testAdditionalPropertiesReference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties |
| [**testBodyWithBinary()**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | |
| [**testBodyWithFileSchema()**](FakeApi.md#testBodyWithFileSchema) | **PUT** /fake/body-with-file-schema | |
@ -530,6 +535,276 @@ No authorization required
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseEndpoint()`
```php
fakeWith400And4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400ResponseEndpoint()`
```php
fakeWith400ResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400ResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400ResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseEndpoint()`
```php
fakeWith4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `testAdditionalPropertiesReference()`
```php

View File

@ -0,0 +1,10 @@
# # ErrorResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**response_code** | **int** | | [optional]
**error** | **string** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

View File

@ -35,6 +35,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;
@ -184,36 +186,15 @@ class AnotherFakeApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\Client', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Client' !== '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\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -228,34 +209,11 @@ class AnotherFakeApi
);
}
$returnType = '\OpenAPI\Client\Model\Client';
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\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -265,8 +223,9 @@ class AnotherFakeApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -462,4 +421,47 @@ class AnotherFakeApi
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;
}
}

View File

@ -35,6 +35,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;
@ -176,36 +178,15 @@ class DefaultApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
default:
if (in_array('\OpenAPI\Client\Model\FooGetDefaultResponse', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' !== '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\FooGetDefaultResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\FooGetDefaultResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -220,34 +201,11 @@ class DefaultApi
);
}
$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
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\FooGetDefaultResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
default:
@ -257,8 +215,9 @@ class DefaultApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -430,4 +389,47 @@ class DefaultApi
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;
}
}

View File

@ -35,6 +35,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;
@ -184,36 +186,15 @@ class FakeClassnameTags123Api
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\Client', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Client' !== '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\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -228,34 +209,11 @@ class FakeClassnameTags123Api
);
}
$returnType = '\OpenAPI\Client\Model\Client';
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\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -265,8 +223,9 @@ class FakeClassnameTags123Api
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -467,4 +426,47 @@ class FakeClassnameTags123Api
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;
}
}

View File

@ -35,6 +35,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;
@ -251,10 +253,10 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -602,10 +604,10 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -848,36 +850,15 @@ class PetApi
$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(
@ -892,34 +873,11 @@ class PetApi
);
}
$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:
@ -929,8 +887,9 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1178,36 +1137,15 @@ class PetApi
$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(
@ -1222,34 +1160,11 @@ class PetApi
);
}
$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:
@ -1259,8 +1174,9 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1509,36 +1425,15 @@ class PetApi
$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(
@ -1553,34 +1448,11 @@ class PetApi
);
}
$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:
@ -1590,8 +1462,9 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1878,10 +1751,10 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2233,10 +2106,10 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2498,36 +2371,15 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\ApiResponse', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\ApiResponse' !== '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\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -2542,34 +2394,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
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\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2579,8 +2408,9 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2865,36 +2695,15 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\ApiResponse', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\ApiResponse' !== '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\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -2909,34 +2718,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
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\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2946,8 +2732,9 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3186,4 +2973,47 @@ class PetApi
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;
}
}

View File

@ -35,6 +35,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;
@ -194,10 +196,10 @@ class StoreApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -421,36 +423,15 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('array<string,int>', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('array<string,int>' !== '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, 'array<string,int>', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'array<string,int>',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -465,34 +446,11 @@ class StoreApi
);
}
$returnType = 'array<string,int>';
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(
'array<string,int>',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -502,8 +460,9 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -728,36 +687,15 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\Order', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Order' !== '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\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -772,34 +710,11 @@ class StoreApi
);
}
$returnType = '\OpenAPI\Client\Model\Order';
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\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -809,8 +724,9 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1057,36 +973,15 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\Order', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Order' !== '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\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -1101,34 +996,11 @@ class StoreApi
);
}
$returnType = '\OpenAPI\Client\Model\Order';
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\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1138,8 +1010,9 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1335,4 +1208,47 @@ class StoreApi
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;
}
}

View File

@ -35,6 +35,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;
@ -206,10 +208,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -437,10 +439,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -668,10 +670,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -899,10 +901,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1130,36 +1132,15 @@ class UserApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if (in_array('\OpenAPI\Client\Model\User', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\User' !== '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\User', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\User',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
@ -1174,34 +1155,11 @@ class UserApi
);
}
$returnType = '\OpenAPI\Client\Model\User';
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\User',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1211,8 +1169,9 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1457,36 +1416,15 @@ class UserApi
$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(
@ -1501,34 +1439,11 @@ class UserApi
);
}
$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:
@ -1538,8 +1453,9 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1800,10 +1716,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2015,10 +1931,10 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2222,4 +2138,47 @@ class UserApi
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;
}
}

View File

@ -0,0 +1,441 @@
<?php
/**
* ErrorResponse
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* ErrorResponse Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class ErrorResponse implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'ErrorResponse';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'response_code' => 'int',
'error' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'response_code' => null,
'error' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'response_code' => false,
'error' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'response_code' => 'response_code',
'error' => 'error'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'response_code' => 'setResponseCode',
'error' => 'setError'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'response_code' => 'getResponseCode',
'error' => 'getError'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(?array $data = null)
{
$this->setIfExists('response_code', $data ?? [], null);
$this->setIfExists('error', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets response_code
*
* @return int|null
*/
public function getResponseCode(): ?int
{
return $this->container['response_code'];
}
/**
* Sets response_code
*
* @param int|null $response_code response_code
*
* @return $this
*/
public function setResponseCode(?int $response_code): static
{
if (is_null($response_code)) {
throw new InvalidArgumentException('non-nullable response_code cannot be null');
}
$this->container['response_code'] = $response_code;
return $this;
}
/**
* Gets error
*
* @return string|null
*/
public function getError(): ?string
{
return $this->container['error'];
}
/**
* Sets error
*
* @param string|null $error error
*
* @return $this
*/
public function setError(?string $error): static
{
if (is_null($error)) {
throw new InvalidArgumentException('non-nullable error cannot be null');
}
$this->container['error'] = $error;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
* ErrorResponseTest
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Please update the test case below to test the model.
*/
namespace OpenAPI\Client\Test\Model;
use PHPUnit\Framework\TestCase;
/**
* ErrorResponseTest Class Doc Comment
*
* @description ErrorResponse
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class ErrorResponseTest extends TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass(): void
{
}
/**
* Setup before running each test case
*/
public function setUp(): void
{
}
/**
* Clean up after running each test case
*/
public function tearDown(): void
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass(): void
{
}
/**
* Test "ErrorResponse"
*/
public function testErrorResponse()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "response_code"
*/
public function testPropertyResponseCode()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "error"
*/
public function testPropertyError()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
}

View File

@ -28,6 +28,7 @@ docs/Model/EnumArrays.md
docs/Model/EnumClass.md
docs/Model/EnumTest.md
docs/Model/EnumWithNameAndDescription.md
docs/Model/ErrorResponse.md
docs/Model/FakeBigDecimalMap200Response.md
docs/Model/File.md
docs/Model/FileSchemaTestClass.md
@ -89,6 +90,7 @@ lib/Model/EnumArrays.php
lib/Model/EnumClass.php
lib/Model/EnumTest.php
lib/Model/EnumWithNameAndDescription.php
lib/Model/ErrorResponse.php
lib/Model/FakeBigDecimalMap200Response.php
lib/Model/File.php
lib/Model/FileSchemaTestClass.php

View File

@ -82,6 +82,11 @@ Class | Method | HTTP request | Description
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
*FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/Api/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
*FakeApi* | [**fakeWith400And4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseendpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType
*FakeApi* | [**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType
*FakeApi* | [**fakeWith400ResponseEndpoint**](docs/Api/FakeApi.md#fakewith400responseendpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseendpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType
*FakeApi* | [**getParameterNameMapping**](docs/Api/FakeApi.md#getparameternamemapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
*FakeApi* | [**testAdditionalPropertiesReference**](docs/Api/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties
*FakeApi* | [**testBodyWithBinary**](docs/Api/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
@ -140,6 +145,7 @@ Class | Method | HTTP request | Description
- [EnumClass](docs/Model/EnumClass.md)
- [EnumTest](docs/Model/EnumTest.md)
- [EnumWithNameAndDescription](docs/Model/EnumWithNameAndDescription.md)
- [ErrorResponse](docs/Model/ErrorResponse.md)
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
- [File](docs/Model/File.md)
- [FileSchemaTestClass](docs/Model/FileSchemaTestClass.md)

View File

@ -13,6 +13,11 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati
| [**fakeOuterNumberSerialize()**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | |
| [**fakeOuterStringSerialize()**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | |
| [**fakePropertyEnumIntegerSerialize()**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int | |
| [**fakeWith400And4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseEndpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType |
| [**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType |
| [**fakeWith400ResponseEndpoint()**](FakeApi.md#fakeWith400ResponseEndpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType |
| [**fakeWith4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseEndpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType |
| [**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType |
| [**getParameterNameMapping()**](FakeApi.md#getParameterNameMapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test |
| [**testAdditionalPropertiesReference()**](FakeApi.md#testAdditionalPropertiesReference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties |
| [**testBodyWithBinary()**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary | |
@ -530,6 +535,276 @@ No authorization required
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseEndpoint()`
```php
fakeWith400And4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400ResponseEndpoint()`
```php
fakeWith400ResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400ResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400ResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseEndpoint()`
```php
fakeWith4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
| Name | Type | Description | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `getParameterNameMapping()`
```php

View File

@ -0,0 +1,10 @@
# # ErrorResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**response_code** | **int** | | [optional]
**error** | **string** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -181,34 +183,15 @@ class AnotherFakeApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Client' !== '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\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -222,34 +205,11 @@ class AnotherFakeApi
);
}
$returnType = '\OpenAPI\Client\Model\Client';
if ($returnType === '\SplFileObject') {
$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\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -259,8 +219,10 @@ class AnotherFakeApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -447,4 +409,47 @@ class AnotherFakeApi
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -175,34 +177,15 @@ class DefaultApi
switch($statusCode) {
default:
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' !== '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\FooGetDefaultResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\FooGetDefaultResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -216,34 +199,11 @@ class DefaultApi
);
}
$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
if ($returnType === '\SplFileObject') {
$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\FooGetDefaultResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
default:
@ -253,8 +213,10 @@ class DefaultApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -420,4 +382,47 @@ class DefaultApi
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -181,34 +183,15 @@ class FakeClassnameTags123Api
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Client' !== '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\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -222,34 +205,11 @@ class FakeClassnameTags123Api
);
}
$returnType = '\OpenAPI\Client\Model\Client';
if ($returnType === '\SplFileObject') {
$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\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -259,8 +219,10 @@ class FakeClassnameTags123Api
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -452,4 +414,47 @@ class FakeClassnameTags123Api
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -244,10 +246,11 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -572,10 +575,11 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -803,34 +807,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') {
$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(
sprintf(
@ -844,34 +829,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\Pet[]';
if ($returnType === '\SplFileObject') {
$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:
@ -881,8 +843,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1118,34 +1082,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') {
$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(
sprintf(
@ -1159,34 +1104,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\Pet[]';
if ($returnType === '\SplFileObject') {
$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:
@ -1196,8 +1118,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1434,34 +1358,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet' === '\SplFileObject') {
$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(
sprintf(
@ -1475,34 +1380,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\Pet';
if ($returnType === '\SplFileObject') {
$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:
@ -1512,8 +1394,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1781,10 +1665,11 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2111,10 +1996,11 @@ class PetApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2354,34 +2240,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\ApiResponse' !== '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\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -2395,34 +2262,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$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\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2432,8 +2276,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2695,34 +2541,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\ApiResponse' !== '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\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -2736,34 +2563,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$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\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2773,8 +2577,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3054,34 +2860,15 @@ class PetApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\ApiResponse' !== '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\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -3095,34 +2882,11 @@ class PetApi
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$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\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -3132,8 +2896,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -3418,4 +3184,47 @@ class PetApi
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -188,10 +190,11 @@ class StoreApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -405,34 +408,15 @@ class StoreApi
switch($statusCode) {
case 200:
if ('array<string,int>' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('array<string,int>' !== '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, 'array<string,int>', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'array<string,int>',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -446,34 +430,11 @@ class StoreApi
);
}
$returnType = 'array<string,int>';
if ($returnType === '\SplFileObject') {
$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(
'array<string,int>',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -483,8 +444,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -700,34 +663,15 @@ class StoreApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Order' !== '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\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -741,34 +685,11 @@ class StoreApi
);
}
$returnType = '\OpenAPI\Client\Model\Order';
if ($returnType === '\SplFileObject') {
$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\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -778,8 +699,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1014,34 +937,15 @@ class StoreApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\Order' !== '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\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -1055,34 +959,11 @@ class StoreApi
);
}
$returnType = '\OpenAPI\Client\Model\Order';
if ($returnType === '\SplFileObject') {
$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\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1092,8 +973,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1280,4 +1163,47 @@ class StoreApi
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -34,6 +34,8 @@ use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
@ -200,10 +202,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -416,10 +419,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -632,10 +636,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -848,10 +853,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1067,34 +1073,15 @@ class UserApi
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\User' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\User' !== '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\User', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\User',
$request,
$response,
);
}
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
@ -1108,34 +1095,11 @@ class UserApi
);
}
$returnType = '\OpenAPI\Client\Model\User';
if ($returnType === '\SplFileObject') {
$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\User',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1145,8 +1109,10 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1377,34 +1343,15 @@ class UserApi
switch($statusCode) {
case 200:
if ('string' === '\SplFileObject') {
$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(
sprintf(
@ -1418,34 +1365,11 @@ class UserApi
);
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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:
@ -1455,8 +1379,10 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1701,10 +1627,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1902,10 +1829,11 @@ class UserApi
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2097,4 +2025,47 @@ class UserApi
return $options;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -0,0 +1,443 @@
<?php
/**
* ErrorResponse
*
* PHP version 8.1
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use \ArrayAccess;
use \OpenAPI\Client\ObjectSerializer;
/**
* ErrorResponse Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements \ArrayAccess<string, mixed>
*/
class ErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'ErrorResponse';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'response_code' => 'int',
'error' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
protected static $openAPIFormats = [
'response_code' => null,
'error' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'response_code' => false,
'error' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPITypes()
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPIFormats()
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param boolean[] $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var string[]
*/
protected static $attributeMap = [
'response_code' => 'response_code',
'error' => 'error'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var string[]
*/
protected static $setters = [
'response_code' => 'setResponseCode',
'error' => 'setError'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var string[]
*/
protected static $getters = [
'response_code' => 'getResponseCode',
'error' => 'getError'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array
*/
public static function attributeMap()
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array
*/
public static function setters()
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array
*/
public static function getters()
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName()
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var mixed[]
*/
protected $container = [];
/**
* Constructor
*
* @param mixed[]|null $data Associated array of property values
* initializing the model
*/
public function __construct(?array $data = null)
{
$this->setIfExists('response_code', $data ?? [], null);
$this->setIfExists('error', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function listInvalidProperties()
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid()
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets response_code
*
* @return int|null
*/
public function getResponseCode()
{
return $this->container['response_code'];
}
/**
* Sets response_code
*
* @param int|null $response_code response_code
*
* @return self
*/
public function setResponseCode($response_code)
{
if (is_null($response_code)) {
throw new \InvalidArgumentException('non-nullable response_code cannot be null');
}
$this->container['response_code'] = $response_code;
return $this;
}
/**
* Gets error
*
* @return string|null
*/
public function getError()
{
return $this->container['error'];
}
/**
* Sets error
*
* @param string|null $error error
*
* @return self
*/
public function setError($error)
{
if (is_null($error)) {
throw new \InvalidArgumentException('non-nullable error cannot be null');
}
$this->container['error'] = $error;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists($offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet($offset, $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString()
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue()
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* ErrorResponseTest
*
* PHP version 7.4
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Please update the test case below to test the model.
*/
namespace OpenAPI\Client\Test\Model;
use PHPUnit\Framework\TestCase;
/**
* ErrorResponseTest Class Doc Comment
*
* @category Class
* @description ErrorResponse
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class ErrorResponseTest extends TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass(): void
{
}
/**
* Setup before running each test case
*/
public function setUp(): void
{
}
/**
* Clean up after running each test case
*/
public function tearDown(): void
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass(): void
{
}
/**
* Test "ErrorResponse"
*/
public function testErrorResponse()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "response_code"
*/
public function testPropertyResponseCode()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "error"
*/
public function testPropertyError()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
}

View File

@ -4,6 +4,8 @@ namespace OpenAPI\Client;
use GuzzleHttp\Psr7\Response;
use OpenAPI\Client\Api\PetApi;
use OpenAPI\Client\Api\FakeApi;
use OpenAPI\Client\Model\ErrorResponse;
use OpenAPI\Client\Model\Pet;
use PHPUnit\Framework\TestCase;
@ -114,4 +116,93 @@ class ResponseTypesTest extends TestCase
$this->fakeHttpClient->setResponse(new Response($statusCode, [], $responseBody));
$this->api->getPetById(123);
}
public function testErrorRangeResponseWithDataType()
{
$responseCode = mt_rand(400, 499);
$responseContent = [
'response_code' => $responseCode,
'error' => 'Some random error',
];
$this->fakeHttpClient->setResponse(new Response($responseCode, [], json_encode($responseContent)));
$api = new FakeApi($this->fakeHttpClient);
$pet = new Model\Pet([]);
$pet->setId(1234);
$result = $api->fakeWith4xxRangeResponseEndpoint($pet);
$this->assertInstanceOf(Model\ErrorResponse::class, $result);
$this->assertEquals($responseContent['response_code'], $result->getResponseCode());
}
public function testErrorRangeResponseWithoutDataType()
{
$responseCode = mt_rand(400, 499);
$responseContent = [];
$this->expectExceptionCode($responseCode);
$this->expectException(ApiException::class);
$this->fakeHttpClient->setResponse(new Response($responseCode, [], json_encode($responseContent)));
$api = new FakeApi($this->fakeHttpClient);
$pet = new Model\Pet([]);
$pet->setId(1234);
$api->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet);
}
public function testError400ResponseWithDataType()
{
$responseCode = 400;
$responseContent = [
'response_code' => $responseCode,
'error' => 'Some random error',
];
$this->fakeHttpClient->setResponse(new Response($responseCode, [], json_encode($responseContent)));
$api = new FakeApi($this->fakeHttpClient);
$pet = new Model\Pet([]);
$pet->setId(1234);
$result = $api->fakeWith400ResponseEndpoint($pet);
$this->assertInstanceOf(Model\ErrorResponse::class, $result);
$this->assertEquals($responseContent['response_code'], $result->getResponseCode());
}
public function testErrorRangeAnd400ResponseWithDataType()
{
$responseCode = mt_rand(400, 499);
$responseContent = [
'response_code' => $responseCode,
'error' => 'Some random error',
];
$this->fakeHttpClient->setResponse(new Response($responseCode, [], json_encode($responseContent)));
$api = new FakeApi($this->fakeHttpClient);
$pet = new Model\Pet([]);
$pet->setId(1234);
$result = $api->fakeWith400And4xxRangeResponseEndpoint($pet);
$this->assertInstanceOf(Model\ErrorResponse::class, $result);
$this->assertEquals($responseContent['response_code'], $result->getResponseCode());
}
public function testErrorRangeAnd400ResponseWithoutDataType()
{
$responseCode = mt_rand(400, 499);
$responseContent = [];
$this->expectExceptionCode($responseCode);
$this->expectException(ApiException::class);
$this->fakeHttpClient->setResponse(new Response($responseCode, [], json_encode($responseContent)));
$api = new FakeApi($this->fakeHttpClient);
$pet = new Model\Pet([]);
$pet->setId(1234);
$api->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet);
}
}

View File

@ -28,6 +28,7 @@ docs/Model/EnumArrays.md
docs/Model/EnumClass.md
docs/Model/EnumTest.md
docs/Model/EnumWithNameAndDescription.md
docs/Model/ErrorResponse.md
docs/Model/FakeBigDecimalMap200Response.md
docs/Model/File.md
docs/Model/FileSchemaTestClass.md
@ -90,6 +91,7 @@ lib/Model/EnumArrays.php
lib/Model/EnumClass.php
lib/Model/EnumTest.php
lib/Model/EnumWithNameAndDescription.php
lib/Model/ErrorResponse.php
lib/Model/FakeBigDecimalMap200Response.php
lib/Model/File.php
lib/Model/FileSchemaTestClass.php

View File

@ -94,6 +94,11 @@ Class | Method | HTTP request | Description
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
*FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/Api/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
*FakeApi* | [**fakeWith400And4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseendpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType
*FakeApi* | [**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith400and4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType
*FakeApi* | [**fakeWith400ResponseEndpoint**](docs/Api/FakeApi.md#fakewith400responseendpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseendpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType
*FakeApi* | [**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint**](docs/Api/FakeApi.md#fakewith4xxrangeresponseno4xxdatatypeendpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType
*FakeApi* | [**getParameterNameMapping**](docs/Api/FakeApi.md#getparameternamemapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
*FakeApi* | [**testAdditionalPropertiesReference**](docs/Api/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties
*FakeApi* | [**testBodyWithBinary**](docs/Api/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
@ -152,6 +157,7 @@ Class | Method | HTTP request | Description
- [EnumClass](docs/Model/EnumClass.md)
- [EnumTest](docs/Model/EnumTest.md)
- [EnumWithNameAndDescription](docs/Model/EnumWithNameAndDescription.md)
- [ErrorResponse](docs/Model/ErrorResponse.md)
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
- [File](docs/Model/File.md)
- [FileSchemaTestClass](docs/Model/FileSchemaTestClass.md)

View File

@ -13,6 +13,11 @@ Method | HTTP request | Description
[**fakeOuterNumberSerialize()**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
[**fakeOuterStringSerialize()**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
[**fakePropertyEnumIntegerSerialize()**](FakeApi.md#fakePropertyEnumIntegerSerialize) | **POST** /fake/property/enum-int |
[**fakeWith400And4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseEndpoint) | **POST** /fake/with_400_and_4xx_range_response/endpoint | test endpoint with 400 and 400-499 range response http code with dataType
[**fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_400_and_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400 and 400-499 range response http code without dataType
[**fakeWith400ResponseEndpoint()**](FakeApi.md#fakeWith400ResponseEndpoint) | **POST** /fake/with_400_response/endpoint | test endpoint with 400 response http code with dataType
[**fakeWith4xxRangeResponseEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseEndpoint) | **POST** /fake/with_4xx_range_response/endpoint | test endpoint with 400-499 range response http code with dataType
[**fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()**](FakeApi.md#fakeWith4xxRangeResponseNo4xxDatatypeEndpoint) | **POST** /fake/with_4xx_range_response_no_4xx_datatype/endpoint | test endpoint with 400-499 range response http code without dataType
[**getParameterNameMapping()**](FakeApi.md#getParameterNameMapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
[**testAdditionalPropertiesReference()**](FakeApi.md#testAdditionalPropertiesReference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties
[**testBodyWithBinary()**](FakeApi.md#testBodyWithBinary) | **PUT** /fake/body-with-binary |
@ -530,6 +535,276 @@ No authorization required
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseEndpoint()`
```php
fakeWith400And4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 and 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith400ResponseEndpoint()`
```php
fakeWith400ResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400 response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith400ResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith400ResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseEndpoint()`
```php
fakeWith4xxRangeResponseEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code with dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `fakeWith4xxRangeResponseNo4xxDatatypeEndpoint()`
```php
fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet): \OpenAPI\Client\Model\Pet
```
test endpoint with 400-499 range response http code without dataType
### Example
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
new GuzzleHttp\Client()
);
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
try {
$result = $apiInstance->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint($pet);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FakeApi->fakeWith4xxRangeResponseNo4xxDatatypeEndpoint: ', $e->getMessage(), PHP_EOL;
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
### Return type
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: `application/json`, `application/xml`
- **Accept**: `application/json`
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
## `getParameterNameMapping()`
```php

View File

@ -0,0 +1,10 @@
# # ErrorResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**response_code** | **int** | | [optional]
**error** | **string** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -230,34 +231,36 @@ class AnotherFakeApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Client';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -267,8 +270,10 @@ class AnotherFakeApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -489,4 +494,47 @@ class AnotherFakeApi
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -224,34 +225,36 @@ class DefaultApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
default:
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\FooGetDefaultResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\FooGetDefaultResponse',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\FooGetDefaultResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
default:
@ -261,8 +264,10 @@ class DefaultApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -464,4 +469,47 @@ class DefaultApi
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -230,34 +231,36 @@ class FakeClassnameTags123Api
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Client';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Client',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -267,8 +270,10 @@ class FakeClassnameTags123Api
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -494,4 +499,47 @@ class FakeClassnameTags123Api
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -239,11 +240,13 @@ class PetApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -471,11 +474,13 @@ class PetApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -692,34 +697,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet[]', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Pet[]',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Pet[]';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
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:
@ -729,8 +736,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -949,34 +958,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet[]', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Pet[]',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Pet[]';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
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:
@ -986,8 +997,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1207,34 +1220,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Pet' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Pet',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Pet';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
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:
@ -1244,8 +1259,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1475,11 +1492,13 @@ class PetApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1709,11 +1728,13 @@ class PetApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1941,34 +1962,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1978,8 +2001,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2225,34 +2250,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2262,8 +2289,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2527,34 +2556,36 @@ class PetApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\ApiResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\ApiResponse',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -2564,8 +2595,10 @@ class PetApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -2877,4 +2910,47 @@ class PetApi
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -229,11 +230,13 @@ class StoreApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -437,34 +440,36 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('array<string,int>' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, 'array<string,int>', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'array<string,int>',
$request,
$response,
);
}
$returnType = 'array<string,int>';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'array<string,int>',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -474,8 +479,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -679,34 +686,36 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Order';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -716,8 +725,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -940,34 +951,36 @@ class StoreApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Order', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\Order';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\Order',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -977,8 +990,10 @@ class StoreApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1199,4 +1214,47 @@ class StoreApi
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -48,6 +48,7 @@ use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface;
@ -229,11 +230,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -436,11 +439,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -643,11 +648,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -850,11 +857,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1060,34 +1069,36 @@ class UserApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\User' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\User', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\User',
$request,
$response,
);
}
$returnType = '\OpenAPI\Client\Model\User';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'\OpenAPI\Client\Model\User',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1097,8 +1108,10 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1316,34 +1329,36 @@ class UserApi
$statusCode = $response->getStatusCode();
switch($statusCode) {
case 200:
if ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'string',
$request,
$response,
);
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
(string) $request->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
return $this->handleResponseWithDataType(
'string',
$request,
$response,
);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@ -1353,8 +1368,10 @@ class UserApi
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
throw $e;
}
throw $e;
}
}
@ -1590,11 +1607,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -1784,11 +1803,13 @@ class UserApi
$statusCode = $response->getStatusCode();
return [null, $statusCode, $response->getHeaders()];
return [null, $statusCode, $response->getHeaders()];
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
@ -2016,4 +2037,47 @@ class UserApi
return $uri;
}
private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
ResponseInterface $response
): array {
if ($dataType === '\SplFileObject') {
$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;
}
}

View File

@ -0,0 +1,443 @@
<?php
/**
* ErrorResponse
*
* PHP version 8.1
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use \ArrayAccess;
use \OpenAPI\Client\ObjectSerializer;
/**
* ErrorResponse Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements \ArrayAccess<string, mixed>
*/
class ErrorResponse implements ModelInterface, ArrayAccess, \JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'ErrorResponse';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'response_code' => 'int',
'error' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
protected static $openAPIFormats = [
'response_code' => null,
'error' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'response_code' => false,
'error' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPITypes()
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPIFormats()
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return boolean[]
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param boolean[] $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var string[]
*/
protected static $attributeMap = [
'response_code' => 'response_code',
'error' => 'error'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var string[]
*/
protected static $setters = [
'response_code' => 'setResponseCode',
'error' => 'setError'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var string[]
*/
protected static $getters = [
'response_code' => 'getResponseCode',
'error' => 'getError'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array
*/
public static function attributeMap()
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array
*/
public static function setters()
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array
*/
public static function getters()
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName()
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var mixed[]
*/
protected $container = [];
/**
* Constructor
*
* @param mixed[]|null $data Associated array of property values
* initializing the model
*/
public function __construct(?array $data = null)
{
$this->setIfExists('response_code', $data ?? [], null);
$this->setIfExists('error', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function listInvalidProperties()
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid()
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets response_code
*
* @return int|null
*/
public function getResponseCode()
{
return $this->container['response_code'];
}
/**
* Sets response_code
*
* @param int|null $response_code response_code
*
* @return self
*/
public function setResponseCode($response_code)
{
if (is_null($response_code)) {
throw new \InvalidArgumentException('non-nullable response_code cannot be null');
}
$this->container['response_code'] = $response_code;
return $this;
}
/**
* Gets error
*
* @return string|null
*/
public function getError()
{
return $this->container['error'];
}
/**
* Sets error
*
* @param string|null $error error
*
* @return self
*/
public function setError($error)
{
if (is_null($error)) {
throw new \InvalidArgumentException('non-nullable error cannot be null');
}
$this->container['error'] = $error;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists($offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet($offset, $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset($offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString()
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue()
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* ErrorResponseTest
*
* PHP version 7.4
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
* Generated by: https://openapi-generator.tech
* Generator version: 7.13.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Please update the test case below to test the model.
*/
namespace OpenAPI\Client\Test\Model;
use PHPUnit\Framework\TestCase;
/**
* ErrorResponseTest Class Doc Comment
*
* @category Class
* @description ErrorResponse
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class ErrorResponseTest extends TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass(): void
{
}
/**
* Setup before running each test case
*/
public function setUp(): void
{
}
/**
* Clean up after running each test case
*/
public function tearDown(): void
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass(): void
{
}
/**
* Test "ErrorResponse"
*/
public function testErrorResponse()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "response_code"
*/
public function testPropertyResponseCode()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
/**
* Test attribute "error"
*/
public function testPropertyError()
{
// TODO: implement
self::markTestIncomplete('Not implemented');
}
}