Skip to content

Commit

Permalink
Update PHP samples
Browse files Browse the repository at this point in the history
  • Loading branch information
4brunu committed Oct 7, 2024
1 parent 5902af4 commit 4c81563
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,18 +549,6 @@ public function fakeEnumEndpointWithHttpInfo(

$statusCode = $response->getStatusCode();

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()
);
}

switch($statusCode) {
case 200:
Expand Down Expand Up @@ -592,6 +580,19 @@ public function fakeEnumEndpointWithHttpInfo(
];
}

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()
);
}

$returnType = '\OpenAPI\Client\Model\EnumClass';
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
Expand Down
25 changes: 13 additions & 12 deletions samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,6 @@ public function fakeEnumEndpointWithHttpInfo($enum_class, $enum_class_array, $en

$statusCode = $response->getStatusCode();

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()
);
}

switch($statusCode) {
case 200:
Expand Down Expand Up @@ -572,6 +560,19 @@ public function fakeEnumEndpointWithHttpInfo($enum_class, $enum_class_array, $en
];
}

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()
);
}

$returnType = '\OpenAPI\Client\Model\EnumClass';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
Expand Down

0 comments on commit 4c81563

Please sign in to comment.