Open deluxetom opened 3 years ago
Any update on this? There is no way to catch correct response other that 2xx
Current solution is awkward
catch (\Throwable $ex)
{
$errorObject = $ex->getResponseObject();
if ($errorObject instanceof \TTPrices\OpenAPI\Account\Model\JsonApiError) {
die($errorObject->getErrors()[0]);
}
same problem, have commented out:
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
and also on $apiInstance put off http errors off:
$apiInstance = new OPENApi\Client\Api\Class(new GuzzleHttp\Client(['http_errors'=>false]), $config);
Description
The generated PHP code (
case 400:
) is unreachable when a response with HTTP code 400 is defined. It adds that return type to the PHPdoc but it's never returned as the RequestException is caught for anything different than a 2xx. Tools like Psalm will expect a return type that will never be returned.openapi-generator version
v5.0.0-beta2
OpenAPI declaration file content or url
Generation Details
config.json
Steps to reproduce
Generate the client with a model defined for a response different than 2xx
Related issues/PRs
Suggest a fix