Skip to content

Commit

Permalink
PHP: fix ranged status codes (#13012)
Browse files Browse the repository at this point in the history
* PHP: fix ranged status codes

* PHP: update samples
  • Loading branch information
Linux13524 authored Sep 20, 2022
1 parent e6dd608 commit 6a7567e
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/openapi-generator/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ use {{invokerPackage}}\ObjectSerializer;

switch($statusCode) {
{{/-first}}
{{#dataType}}
{{#dataType}}{{^isRange}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
if ('{{{dataType}}}' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
Expand All @@ -277,7 +277,7 @@ use {{invokerPackage}}\ObjectSerializer;
$response->getStatusCode(),
$response->getHeaders()
];
{{/dataType}}
{{/isRange}}{{/dataType}}
{{#-last}}
}
{{/-last}}
Expand Down Expand Up @@ -307,7 +307,7 @@ use {{invokerPackage}}\ObjectSerializer;
} catch (ApiException $e) {
switch ($e->getCode()) {
{{#responses}}
{{#dataType}}
{{#dataType}}{{^isRange}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
Expand All @@ -316,7 +316,7 @@ use {{invokerPackage}}\ObjectSerializer;
);
$e->setResponseObject($data);
break;
{{/dataType}}
{{/isRange}}{{/dataType}}
{{/responses}}
}
throw $e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function call123TestSpecialTagsWithHttpInfo($client)
}

switch($statusCode) {

case 200:
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
Expand All @@ -198,6 +199,7 @@ public function call123TestSpecialTagsWithHttpInfo($client)
$response->getStatusCode(),
$response->getHeaders()
];

}

$returnType = '\OpenAPI\Client\Model\Client';
Expand All @@ -218,6 +220,7 @@ public function call123TestSpecialTagsWithHttpInfo($client)

} catch (ApiException $e) {
switch ($e->getCode()) {

case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
Expand All @@ -226,6 +229,7 @@ public function call123TestSpecialTagsWithHttpInfo($client)
);
$e->setResponseObject($data);
break;

}
throw $e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public function fooGetWithHttpInfo()
}

switch($statusCode) {

default:
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
Expand All @@ -192,6 +193,7 @@ public function fooGetWithHttpInfo()
$response->getStatusCode(),
$response->getHeaders()
];

}

$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
Expand All @@ -212,6 +214,7 @@ public function fooGetWithHttpInfo()

} catch (ApiException $e) {
switch ($e->getCode()) {

default:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
Expand All @@ -220,6 +223,7 @@ public function fooGetWithHttpInfo()
);
$e->setResponseObject($data);
break;

}
throw $e;
}
Expand Down
Loading

0 comments on commit 6a7567e

Please sign in to comment.