From 41bf436d52270571fa6e173f439a976d40fc4e1d Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 5 Oct 2021 14:05:38 +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 --- .../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 66934f56449b..60989ca57395 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 e7d2f939ef29..6a69cead65d3 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 63a8fef63e75..d884b222adb1 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 a7b64c5446b6..214509705f70 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 @@ 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 @@ public function call123TestSpecialTagsWithHttpInfo($client) $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 @@ public function call123TestSpecialTagsRequest($client) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -367,7 +375,7 @@ public function call123TestSpecialTagsRequest($client) $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 7f5787b3de61..6ff0f1fd3cd6 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 @@ 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 @@ public function fooGetWithHttpInfo() $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 @@ public function fooGetRequest() } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -342,7 +350,7 @@ public function fooGetRequest() $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 a4996ace4185..6ecc46aefd7f 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 @@ 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 @@ public function fakeHealthGetWithHttpInfo() $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 @@ public function fakeHealthGetRequest() } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -350,7 +358,7 @@ public function fakeHealthGetRequest() $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 @@ public function fakeHttpSignatureTestWithHttpInfo($pet, $query_1 = null, $header $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 @@ public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -592,7 +607,7 @@ public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = $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 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) $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 @@ public function fakeOuterBooleanSerializeRequest($body = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -840,7 +862,7 @@ public function fakeOuterBooleanSerializeRequest($body = null) $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 @@ public function fakeOuterCompositeSerializeWithHttpInfo($outer_composite = null) $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 @@ public function fakeOuterCompositeSerializeRequest($outer_composite = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1088,7 +1117,7 @@ public function fakeOuterCompositeSerializeRequest($outer_composite = null) $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 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) $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 @@ public function fakeOuterNumberSerializeRequest($body = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1336,7 +1372,7 @@ public function fakeOuterNumberSerializeRequest($body = null) $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 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) $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 @@ public function fakeOuterStringSerializeRequest($body = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1584,7 +1627,7 @@ public function fakeOuterStringSerializeRequest($body = null) $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 @@ public function fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_ $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 @@ public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_ } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1838,7 +1888,7 @@ public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_ $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 @@ public function testBodyWithBinaryWithHttpInfo($body) $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 @@ public function testBodyWithBinaryRequest($body) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2047,7 +2104,7 @@ public function testBodyWithBinaryRequest($body) $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 @@ public function testBodyWithFileSchemaWithHttpInfo($file_schema_test_class) $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 @@ public function testBodyWithFileSchemaRequest($file_schema_test_class) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2256,7 +2320,7 @@ public function testBodyWithFileSchemaRequest($file_schema_test_class) $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 @@ public function testBodyWithQueryParamsWithHttpInfo($query, $user) $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 @@ public function testBodyWithQueryParamsRequest($query, $user) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2487,7 +2558,7 @@ public function testBodyWithQueryParamsRequest($query, $user) $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 @@ public function testClientModelWithHttpInfo($client) $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 @@ public function testClientModelRequest($client) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2749,7 +2827,7 @@ public function testClientModelRequest($client) $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 @@ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_wi $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 @@ public function testEndpointParametersRequest($number, $double, $pattern_without $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 @@ public function testEndpointParametersRequest($number, $double, $pattern_without } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3158,7 +3243,7 @@ public function testEndpointParametersRequest($number, $double, $pattern_without $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 @@ public function testEnumParametersWithHttpInfo($enum_header_string_array = null, $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 @@ public function testEnumParametersRequest($enum_header_string_array = null, $enu } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3461,7 +3553,7 @@ public function testEnumParametersRequest($enum_header_string_array = null, $enu $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 @@ public function testGroupParametersWithHttpInfo($associative_array) $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 @@ public function testGroupParametersRequest($associative_array) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -3783,7 +3882,7 @@ public function testGroupParametersRequest($associative_array) $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 @@ public function testInlineAdditionalPropertiesWithHttpInfo($request_body) $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 @@ public function testInlineAdditionalPropertiesRequest($request_body) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4000,7 +4106,7 @@ public function testInlineAdditionalPropertiesRequest($request_body) $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 @@ public function testJsonFormDataWithHttpInfo($param, $param2) $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 @@ public function testJsonFormDataRequest($param, $param2) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4230,7 +4343,7 @@ public function testJsonFormDataRequest($param, $param2) $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 @@ public function testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $ $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 @@ public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -4554,7 +4674,7 @@ public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $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 daae07ccfa79..bb77a9f8e4f7 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 @@ 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 @@ public function testClassnameWithHttpInfo($client) $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 @@ public function testClassnameRequest($client) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -372,7 +380,7 @@ public function testClassnameRequest($client) $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 fe1e265c59cd..511b4ee2c1ec 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 @@ 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 @@ public function addPetWithHttpInfo($pet) $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 @@ public function addPetRequest($pet) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -352,7 +360,7 @@ public function addPetRequest($pet) } $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 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null) $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 @@ public function deletePetRequest($pet_id, $api_key = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -584,7 +599,7 @@ public function deletePetRequest($pet_id, $api_key = null) $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 @@ public function findPetsByStatusWithHttpInfo($status) $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 @@ public function findPetsByStatusRequest($status) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -851,7 +873,7 @@ public function findPetsByStatusRequest($status) $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 @@ public function findPetsByTagsWithHttpInfo($tags) $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 @@ public function findPetsByTagsRequest($tags) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1124,7 +1153,7 @@ public function findPetsByTagsRequest($tags) $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 @@ public function getPetByIdWithHttpInfo($pet_id) $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 @@ public function getPetByIdRequest($pet_id) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1393,7 +1429,7 @@ public function getPetByIdRequest($pet_id) $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 @@ public function updatePetWithHttpInfo($pet) $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 @@ public function updatePetRequest($pet) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1640,7 +1683,7 @@ public function updatePetRequest($pet) } $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 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n $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 @@ public function updatePetWithFormRequest($pet_id, $name = null, $status = null) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1881,7 +1931,7 @@ public function updatePetWithFormRequest($pet_id, $name = null, $status = null) $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 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi $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 @@ public function uploadFileRequest($pet_id, $additional_metadata = null, $file = $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 @@ public function uploadFileRequest($pet_id, $additional_metadata = null, $file = } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2175,7 +2232,7 @@ public function uploadFileRequest($pet_id, $additional_metadata = null, $file = $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 @@ public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $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 @@ public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $addi $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 @@ public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $addi } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -2475,7 +2539,7 @@ public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $addi $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 0d352de63fc5..f7be16f367f9 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 @@ 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 @@ public function deleteOrderWithHttpInfo($order_id) $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 @@ public function deleteOrderRequest($order_id) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -324,7 +332,7 @@ public function deleteOrderRequest($order_id) $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 @@ public function getInventoryWithHttpInfo() $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 @@ public function getInventoryRequest() } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -574,7 +589,7 @@ public function getInventoryRequest() $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 @@ public function getOrderByIdWithHttpInfo($order_id) $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 @@ public function getOrderByIdRequest($order_id) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -845,7 +867,7 @@ public function getOrderByIdRequest($order_id) $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 @@ public function placeOrderWithHttpInfo($order) $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 @@ public function placeOrderRequest($order) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1107,7 +1136,7 @@ public function placeOrderRequest($order) $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 52ec5b1c5ca1..58e47e5209c6 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 @@ 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 @@ public function createUserWithHttpInfo($user) $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 @@ public function createUserRequest($user) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -322,7 +330,7 @@ public function createUserRequest($user) $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 @@ public function createUsersWithArrayInputWithHttpInfo($user) $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 @@ public function createUsersWithArrayInputRequest($user) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -539,7 +554,7 @@ public function createUsersWithArrayInputRequest($user) $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 @@ public function createUsersWithListInputWithHttpInfo($user) $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 @@ public function createUsersWithListInputRequest($user) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -756,7 +778,7 @@ public function createUsersWithListInputRequest($user) $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 @@ public function deleteUserWithHttpInfo($username) $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 @@ public function deleteUserRequest($username) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -975,7 +1004,7 @@ public function deleteUserRequest($username) $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 @@ public function getUserByNameWithHttpInfo($username) $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 @@ public function getUserByNameRequest($username) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1239,7 +1275,7 @@ public function getUserByNameRequest($username) $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 @@ public function loginUserWithHttpInfo($username, $password) $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 @@ public function loginUserRequest($username, $password) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1528,7 +1571,7 @@ public function loginUserRequest($username, $password) $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 @@ public function logoutUserWithHttpInfo() $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 @@ public function logoutUserRequest() } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1728,7 +1778,7 @@ public function logoutUserRequest() $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 @@ public function updateUserWithHttpInfo($username, $user) $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 @@ public function updateUserRequest($username, $user) } else { // for HTTP post (form) - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); } } @@ -1964,7 +2021,7 @@ public function updateUserRequest($username, $user) $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 d93b8f8b0b36..f5e32d4c6593 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 @@ 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 @@ public function setResponse(ResponseInterface $response = null) * @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'); }