From 69452360abf3df1ee5094b92bfa853ba5c6b83db Mon Sep 17 00:00:00 2001 From: Benjamin Heiss <62474921+heissb2342@users.noreply.github.com> Date: Sat, 16 Oct 2021 07:24:11 +0200 Subject: [PATCH] Issue-7869: Update to Guzzle 7, removed all deprecated Guzzle\Psr7 function calls by their static counterparts and updated FakeHttpClient interface to Guzzle7 client (#10585) Co-authored-by: Benjamin --- .../src/main/resources/php/api.mustache | 14 +- .../src/main/resources/php/composer.mustache | 3 +- .../php/OpenAPIClient-php/composer.json | 3 +- .../lib/Api/AnotherFakeApi.php | 12 +- .../OpenAPIClient-php/lib/Api/DefaultApi.php | 12 +- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 190 ++++++++++++++---- .../lib/Api/FakeClassnameTags123Api.php | 12 +- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 104 ++++++++-- .../OpenAPIClient-php/lib/Api/StoreApi.php | 45 ++++- .../php/OpenAPIClient-php/lib/Api/UserApi.php | 89 ++++++-- .../tests/FakeHttpClient.php | 9 +- 11 files changed, 399 insertions(+), 94 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 66934f56449..60989ca5739 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -21,6 +21,7 @@ namespace {{apiPackage}}; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -197,6 +198,13 @@ use {{invokerPackage}}\ObjectSerializer; $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -552,7 +560,7 @@ use {{invokerPackage}}\ObjectSerializer; $formParams['{{baseName}}'] = []; $paramFiles = is_array(${{paramName}}) ? ${{paramName}} : [${{paramName}}]; foreach ($paramFiles as $paramFile) { - $formParams['{{baseName}}'][] = \GuzzleHttp\Psr7\try_fopen( + $formParams['{{baseName}}'][] = \GuzzleHttp\Psr7\Utils::tryFopen( ObjectSerializer::toFormValue($paramFile), 'rb' ); @@ -607,7 +615,7 @@ use {{invokerPackage}}\ObjectSerializer; } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -660,7 +668,7 @@ use {{invokerPackage}}\ObjectSerializer; $operationHost = $operationHosts[$this->hostIndex]; {{/servers.0}} - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( '{{httpMethod}}', {{^servers.0}}$this->config->getHost(){{/servers.0}}{{#servers.0}}$operationHost{{/servers.0}} . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/modules/openapi-generator/src/main/resources/php/composer.mustache b/modules/openapi-generator/src/main/resources/php/composer.mustache index e7d2f939ef2..6a69cead65d 100644 --- a/modules/openapi-generator/src/main/resources/php/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php/composer.mustache @@ -28,7 +28,8 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^2.0" }, "require-dev": { "phpunit/phpunit": "^8.0 || ^9.0", diff --git a/samples/client/petstore/php/OpenAPIClient-php/composer.json b/samples/client/petstore/php/OpenAPIClient-php/composer.json index 63a8fef63e7..d884b222adb 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/composer.json +++ b/samples/client/petstore/php/OpenAPIClient-php/composer.json @@ -22,7 +22,8 @@ "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^7.3", + "guzzlehttp/psr7": "^2.0" }, "require-dev": { "phpunit/phpunit": "^8.0 || ^9.0", diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php index a7b64c5446b..214509705f7 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -157,6 +158,13 @@ class AnotherFakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -351,7 +359,7 @@ class AnotherFakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -367,7 +375,7 @@ class AnotherFakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php index 7f5787b3de6..6ff0f1fd3cd 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -151,6 +152,13 @@ class DefaultApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -326,7 +334,7 @@ class DefaultApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -342,7 +350,7 @@ class DefaultApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index a4996ace418..6ecc46aefd7 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -155,6 +156,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -334,7 +342,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -350,7 +358,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -405,6 +413,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -576,7 +591,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -592,7 +607,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -640,6 +655,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -824,7 +846,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -840,7 +862,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -888,6 +910,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1072,7 +1101,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1088,7 +1117,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1136,6 +1165,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1320,7 +1356,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1336,7 +1372,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1384,6 +1420,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1568,7 +1611,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1584,7 +1627,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1632,6 +1675,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1822,7 +1872,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1838,7 +1888,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1885,6 +1935,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2031,7 +2088,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2047,7 +2104,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2094,6 +2151,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2240,7 +2304,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2256,7 +2320,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2305,6 +2369,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2471,7 +2542,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2487,7 +2558,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2539,6 +2610,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2733,7 +2811,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2749,7 +2827,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2826,6 +2904,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -3083,7 +3168,7 @@ class FakeApi $formParams['binary'] = []; $paramFiles = is_array($binary) ? $binary : [$binary]; foreach ($paramFiles as $paramFile) { - $formParams['binary'][] = \GuzzleHttp\Psr7\try_fopen( + $formParams['binary'][] = \GuzzleHttp\Psr7\Utils::tryFopen( ObjectSerializer::toFormValue($paramFile), 'rb' ); @@ -3138,7 +3223,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3158,7 +3243,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3223,6 +3308,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -3445,7 +3537,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3461,7 +3553,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3526,6 +3618,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -3763,7 +3862,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3783,7 +3882,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -3834,6 +3933,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -3984,7 +4090,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4000,7 +4106,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -4053,6 +4159,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -4214,7 +4327,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4230,7 +4343,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -4289,6 +4402,13 @@ class FakeApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -4538,7 +4658,7 @@ class FakeApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4554,7 +4674,7 @@ class FakeApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php index daae07ccfa7..bb77a9f8e4f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -157,6 +158,13 @@ class FakeClassnameTags123Api $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -351,7 +359,7 @@ class FakeClassnameTags123Api } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -372,7 +380,7 @@ class FakeClassnameTags123Api $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PATCH', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index fe1e265c59c..511b4ee2c1e 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -164,6 +165,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -326,7 +334,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -352,7 +360,7 @@ class PetApi } $operationHost = $operationHosts[$this->hostIndex]; - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), @@ -405,6 +413,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -564,7 +579,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -584,7 +599,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -636,6 +651,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -831,7 +853,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -851,7 +873,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -905,6 +927,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1104,7 +1133,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1124,7 +1153,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1176,6 +1205,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1372,7 +1408,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1393,7 +1429,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1452,6 +1488,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1614,7 +1657,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1640,7 +1683,7 @@ class PetApi } $operationHost = $operationHosts[$this->hostIndex]; - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), @@ -1695,6 +1738,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1861,7 +1911,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1881,7 +1931,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1937,6 +1987,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2116,7 +2173,7 @@ class PetApi $formParams['file'] = []; $paramFiles = is_array($file) ? $file : [$file]; foreach ($paramFiles as $paramFile) { - $formParams['file'][] = \GuzzleHttp\Psr7\try_fopen( + $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( ObjectSerializer::toFormValue($paramFile), 'rb' ); @@ -2155,7 +2212,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2175,7 +2232,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -2231,6 +2288,13 @@ class PetApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -2416,7 +2480,7 @@ class PetApi $formParams['requiredFile'] = []; $paramFiles = is_array($required_file) ? $required_file : [$required_file]; foreach ($paramFiles as $paramFile) { - $formParams['requiredFile'][] = \GuzzleHttp\Psr7\try_fopen( + $formParams['requiredFile'][] = \GuzzleHttp\Psr7\Utils::tryFopen( ObjectSerializer::toFormValue($paramFile), 'rb' ); @@ -2455,7 +2519,7 @@ class PetApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2475,7 +2539,7 @@ class PetApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php index 0d352de63fc..f7be16f367f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -156,6 +157,13 @@ class StoreApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -308,7 +316,7 @@ class StoreApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -324,7 +332,7 @@ class StoreApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -374,6 +382,13 @@ class StoreApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -553,7 +568,7 @@ class StoreApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -574,7 +589,7 @@ class StoreApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -626,6 +641,13 @@ class StoreApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -829,7 +851,7 @@ class StoreApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -845,7 +867,7 @@ class StoreApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -897,6 +919,13 @@ class StoreApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1091,7 +1120,7 @@ class StoreApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1107,7 +1136,7 @@ class StoreApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 52ec5b1c5ca..58e47e5209c 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -30,6 +30,7 @@ namespace OpenAPI\Client\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -156,6 +157,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -306,7 +314,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -322,7 +330,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -373,6 +381,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -523,7 +538,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -539,7 +554,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -590,6 +605,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -740,7 +762,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -756,7 +778,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'POST', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -807,6 +829,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -959,7 +988,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -975,7 +1004,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'DELETE', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1027,6 +1056,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1223,7 +1259,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1239,7 +1275,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1293,6 +1329,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1512,7 +1555,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1528,7 +1571,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1577,6 +1620,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1712,7 +1762,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1728,7 +1778,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), @@ -1781,6 +1831,13 @@ class UserApi $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); } $statusCode = $response->getStatusCode(); @@ -1948,7 +2005,7 @@ class UserApi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1964,7 +2021,7 @@ class UserApi $headers ); - $query = \GuzzleHttp\Psr7\build_query($queryParams); + $query = \GuzzleHttp\Psr7\Query::build($queryParams); return new Request( 'PUT', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php b/samples/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php index d93b8f8b0b3..f5e32d4c659 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php @@ -4,6 +4,7 @@ namespace OpenAPI\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\GuzzleException; +use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -41,23 +42,23 @@ class FakeHttpClient implements ClientInterface * @return ResponseInterface * @throws GuzzleException */ - public function send(RequestInterface $request, array $options = []) + public function send(RequestInterface $request, array $options = []): ResponseInterface { $this->request = $request; return $this->response ?: new Response(200); } - public function sendAsync(RequestInterface $request, array $options = []) + public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface { throw new \RuntimeException('not implemented'); } - public function request($method, $uri, array $options = []) + public function request($method, $uri, array $options = []): ResponseInterface { throw new \RuntimeException('not implemented'); } - public function requestAsync($method, $uri, array $options = []) + public function requestAsync($method, $uri, array $options = []): PromiseInterface { throw new \RuntimeException('not implemented'); }