Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Update GuzzleHttp version to 7 #10585

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions modules/openapi-generator/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'
);
Expand Down Expand Up @@ -607,7 +615,7 @@ use {{invokerPackage}}\ObjectSerializer;

} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
}
}

Expand Down Expand Up @@ -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}" : ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion samples/client/petstore/php/OpenAPIClient-php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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}" : ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -326,7 +334,7 @@ public function fooGetRequest()

} else {
// for HTTP post (form)
$httpBody = \GuzzleHttp\Psr7\build_query($formParams);
$httpBody = \GuzzleHttp\Psr7\Query::build($formParams);
}
}

Expand All @@ -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}" : ''),
Expand Down
Loading