diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 1fa2640c880..a2247273df0 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -50,8 +50,8 @@ use {{invokerPackage}}\ObjectSerializer; /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -84,8 +84,9 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#allParams}} - * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * * @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \InvalidArgumentException * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} @@ -108,8 +109,9 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#allParams}} - * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * * @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) @@ -135,7 +137,11 @@ use {{invokerPackage}}\ObjectSerializer; if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -168,7 +174,11 @@ use {{invokerPackage}}\ObjectSerializer; {{#responses}} {{#dataType}} {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} - $data = ObjectSerializer::deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '{{dataType}}', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; {{/dataType}} @@ -188,16 +198,20 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#allParams}} - * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function {{operationId}}Async({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { - return $this->{{operationId}}AsyncWithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})->then(function ($response) { - return $response[0]; - }); + return $this->{{operationId}}AsyncWithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -210,8 +224,9 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#allParams}} - * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -220,45 +235,55 @@ use {{invokerPackage}}\ObjectSerializer; $returnType = '{{returnType}}'; $request = $this->{{operationId}}Request({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - {{#returnType}} - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + {{#returnType}} + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + {{/returnType}} + {{^returnType}} + return [null, $response->getStatusCode(), $response->getHeaders()]; + {{/returnType}} + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - {{/returnType}} - {{^returnType}} - return [null, $response->getStatusCode(), $response->getHeaders()]; - {{/returnType}} - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation '{{{operationId}}}' * {{#allParams}} - * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -268,7 +293,9 @@ use {{invokerPackage}}\ObjectSerializer; {{#required}} // verify the required parameter '{{paramName}}' is set if (${{paramName}} === null) { - throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); + throw new \InvalidArgumentException( + 'Missing the required parameter ${{paramName}} when calling {{operationId}}' + ); } {{/required}} {{#hasValidation}} @@ -349,7 +376,11 @@ use {{invokerPackage}}\ObjectSerializer; } {{/collectionFormat}} if (${{paramName}} !== null) { - $resourcePath = str_replace('{' . '{{baseName}}' . '}', ObjectSerializer::toPathValue(${{paramName}}), $resourcePath); + $resourcePath = str_replace( + '{' . '{{baseName}}' . '}', + ObjectSerializer::toPathValue(${{paramName}}), + $resourcePath + ); } {{/pathParams}} @@ -365,9 +396,9 @@ use {{invokerPackage}}\ObjectSerializer; {{/isFile}} } {{/formParams}} - {{#bodyParams}} // body params $_tempBody = null; + {{#bodyParams}} if (isset(${{paramName}})) { $_tempBody = ${{paramName}}; } @@ -397,13 +428,15 @@ use {{invokerPackage}}\ObjectSerializer; 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -429,9 +462,6 @@ use {{invokerPackage}}\ObjectSerializer; {{/isOAuth}} {{/authMethods}} - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -443,9 +473,10 @@ use {{invokerPackage}}\ObjectSerializer; $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( '{{httpMethod}}', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php index c6ca2196346..c2e0132a490 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -59,8 +59,8 @@ class FakeApi /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -85,7 +85,8 @@ public function getConfig() * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -100,7 +101,8 @@ public function testCodeInjectEndRnNR($test_code_inject____end____rn_n_r = null) * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -126,7 +128,11 @@ public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -147,15 +153,19 @@ public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testCodeInjectEndRnNRAsync($test_code_inject____end____rn_n_r = null) { - return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end____rn_n_r)->then(function ($response) { - return $response[0]; - }); + return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end____rn_n_r) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -163,7 +173,8 @@ public function testCodeInjectEndRnNRAsync($test_code_inject____end____rn_n_r = * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -172,24 +183,34 @@ public function testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end_ $returnType = ''; $request = $this->testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n_r); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'testCodeInjectEndRnNR' * - * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -209,6 +230,8 @@ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n if ($test_code_inject____end____rn_n_r !== null) { $formParams['test code inject */ ' " =end -- \r\n \n \r'] = ObjectSerializer::toFormValue($test_code_inject____end____rn_n_r); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -234,20 +257,19 @@ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -259,9 +281,10 @@ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PUT', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 83b6d6e01a1..7e6e53dd932 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -56,14 +56,14 @@ Please follow the [installation procedure](#installation--usage) and then run th testSpecialTags($body); + $result = $api_instance->fakeOuterBooleanSerialize($body); print_r($result); } catch (Exception $e) { - echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL; } ?> @@ -75,7 +75,6 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | *FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | @@ -84,7 +83,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters *FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data -*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case +*Fake_classname_tags123Api* | [**testClassname**](docs/Api/Fake_classname_tags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status @@ -105,6 +104,7 @@ Class | Method | HTTP request | Description *UserApi* | [**loginUser**](docs/Api/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system *UserApi* | [**logoutUser**](docs/Api/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session *UserApi* | [**updateUser**](docs/Api/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user +*AnotherfakeApi* | [**testSpecialTags**](docs/Api/AnotherfakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags ## Documentation For Models diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md index 5b443618999..53bd4be8062 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md @@ -1,10 +1,10 @@ -# Swagger\Client\AnotherFakeApi +# Swagger\Client\AnotherfakeApi All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags +[**testSpecialTags**](AnotherfakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags # **testSpecialTags** @@ -19,14 +19,14 @@ To test special tags testSpecialTags($body); print_r($result); } catch (Exception $e) { - echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling AnotherfakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; } ?> ``` diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/Fake_classname_tags123Api.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/Fake_classname_tags123Api.md new file mode 100644 index 00000000000..d5fe15b46fc --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/Fake_classname_tags123Api.md @@ -0,0 +1,57 @@ +# Swagger\Client\Fake_classname_tags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](Fake_classname_tags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **testClassname** +> \Swagger\Client\Model\Client testClassname($body) + +To test class name in snake case + +### Example +```php +setApiKey('api_key_query', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer'); + +$api_instance = new Swagger\Client\Api\Fake_classname_tags123Api(new \Http\Adapter\Guzzle6\Client()); +$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model + +try { + $result = $api_instance->testClassname($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling Fake_classname_tags123Api->testClassname: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**\Swagger\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\Swagger\Client\Model\Client**](../Model/Client.md) + +### Authorization + +[api_key_query](../../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php index f50a1730338..5e5ba412dd9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php @@ -1,6 +1,6 @@ 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -154,7 +160,11 @@ public function testSpecialTagsWithHttpInfo($body) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Client', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Client', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -167,15 +177,19 @@ public function testSpecialTagsWithHttpInfo($body) * * To test special tags * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testSpecialTagsAsync($body) { - return $this->testSpecialTagsAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->testSpecialTagsAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -183,7 +197,8 @@ public function testSpecialTagsAsync($body) * * To test special tags * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -192,38 +207,48 @@ public function testSpecialTagsAsyncWithHttpInfo($body) $returnType = '\Swagger\Client\Model\Client'; $request = $this->testSpecialTagsRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'testSpecialTags' * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -231,7 +256,9 @@ protected function testSpecialTagsRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling testSpecialTags'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling testSpecialTags' + ); } $resourcePath = '/another-fake/dummy'; @@ -273,20 +300,19 @@ protected function testSpecialTagsRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -298,9 +324,10 @@ protected function testSpecialTagsRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PATCH', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php index ac6c71e1178..cf1f539567c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -59,8 +59,8 @@ class FakeApi /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -83,7 +83,8 @@ public function getConfig() /** * Operation fakeOuterBooleanSerialize * - * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\OuterBoolean @@ -97,7 +98,8 @@ public function fakeOuterBooleanSerialize($body = null) /** * Operation fakeOuterBooleanSerializeWithHttpInfo * - * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\OuterBoolean, HTTP status code, HTTP response headers (array of strings) @@ -123,7 +125,11 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -149,7 +155,11 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\OuterBoolean', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\OuterBoolean', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -162,15 +172,19 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) * * * - * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterBooleanSerializeAsync($body = null) { - return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -178,7 +192,8 @@ public function fakeOuterBooleanSerializeAsync($body = null) * * * - * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -187,38 +202,48 @@ public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null) $returnType = '\Swagger\Client\Model\OuterBoolean'; $request = $this->fakeOuterBooleanSerializeRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'fakeOuterBooleanSerialize' * - * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -264,20 +289,19 @@ protected function fakeOuterBooleanSerializeRequest($body = null) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -289,9 +313,10 @@ protected function fakeOuterBooleanSerializeRequest($body = null) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -300,7 +325,8 @@ protected function fakeOuterBooleanSerializeRequest($body = null) /** * Operation fakeOuterCompositeSerialize * - * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\OuterComposite @@ -314,7 +340,8 @@ public function fakeOuterCompositeSerialize($body = null) /** * Operation fakeOuterCompositeSerializeWithHttpInfo * - * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings) @@ -340,7 +367,11 @@ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -366,7 +397,11 @@ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\OuterComposite', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\OuterComposite', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -379,15 +414,19 @@ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) * * * - * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterCompositeSerializeAsync($body = null) { - return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -395,7 +434,8 @@ public function fakeOuterCompositeSerializeAsync($body = null) * * * - * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -404,38 +444,48 @@ public function fakeOuterCompositeSerializeAsyncWithHttpInfo($body = null) $returnType = '\Swagger\Client\Model\OuterComposite'; $request = $this->fakeOuterCompositeSerializeRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'fakeOuterCompositeSerialize' * - * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -481,20 +531,19 @@ protected function fakeOuterCompositeSerializeRequest($body = null) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -506,9 +555,10 @@ protected function fakeOuterCompositeSerializeRequest($body = null) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -517,7 +567,8 @@ protected function fakeOuterCompositeSerializeRequest($body = null) /** * Operation fakeOuterNumberSerialize * - * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\OuterNumber @@ -531,7 +582,8 @@ public function fakeOuterNumberSerialize($body = null) /** * Operation fakeOuterNumberSerializeWithHttpInfo * - * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\OuterNumber, HTTP status code, HTTP response headers (array of strings) @@ -557,7 +609,11 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -583,7 +639,11 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\OuterNumber', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\OuterNumber', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -596,15 +656,19 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) * * * - * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterNumberSerializeAsync($body = null) { - return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -612,7 +676,8 @@ public function fakeOuterNumberSerializeAsync($body = null) * * * - * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -621,38 +686,48 @@ public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null) $returnType = '\Swagger\Client\Model\OuterNumber'; $request = $this->fakeOuterNumberSerializeRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'fakeOuterNumberSerialize' * - * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -698,20 +773,19 @@ protected function fakeOuterNumberSerializeRequest($body = null) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -723,9 +797,10 @@ protected function fakeOuterNumberSerializeRequest($body = null) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -734,7 +809,8 @@ protected function fakeOuterNumberSerializeRequest($body = null) /** * Operation fakeOuterStringSerialize * - * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\OuterString @@ -748,7 +824,8 @@ public function fakeOuterStringSerialize($body = null) /** * Operation fakeOuterStringSerializeWithHttpInfo * - * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\OuterString, HTTP status code, HTTP response headers (array of strings) @@ -774,7 +851,11 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -800,7 +881,11 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\OuterString', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\OuterString', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -813,15 +898,19 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) * * * - * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterStringSerializeAsync($body = null) { - return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -829,7 +918,8 @@ public function fakeOuterStringSerializeAsync($body = null) * * * - * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -838,38 +928,48 @@ public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null) $returnType = '\Swagger\Client\Model\OuterString'; $request = $this->fakeOuterStringSerializeRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'fakeOuterStringSerialize' * - * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -915,20 +1015,19 @@ protected function fakeOuterStringSerializeRequest($body = null) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -940,9 +1039,10 @@ protected function fakeOuterStringSerializeRequest($body = null) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -953,7 +1053,8 @@ protected function fakeOuterStringSerializeRequest($body = null) * * To test \"client\" model * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Client @@ -969,7 +1070,8 @@ public function testClientModel($body) * * To test \"client\" model * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) @@ -995,7 +1097,11 @@ public function testClientModelWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1021,7 +1127,11 @@ public function testClientModelWithHttpInfo($body) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Client', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Client', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -1034,15 +1144,19 @@ public function testClientModelWithHttpInfo($body) * * To test \"client\" model * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testClientModelAsync($body) { - return $this->testClientModelAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->testClientModelAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1050,7 +1164,8 @@ public function testClientModelAsync($body) * * To test \"client\" model * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1059,38 +1174,48 @@ public function testClientModelAsyncWithHttpInfo($body) $returnType = '\Swagger\Client\Model\Client'; $request = $this->testClientModelRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'testClientModel' * - * @param \Swagger\Client\Model\Client $body client model (required) + * @param \Swagger\Client\Model\Client $body client model (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1098,7 +1223,9 @@ protected function testClientModelRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling testClientModel'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling testClientModel' + ); } $resourcePath = '/fake'; @@ -1140,20 +1267,19 @@ protected function testClientModelRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1165,9 +1291,10 @@ protected function testClientModelRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PATCH', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1178,20 +1305,21 @@ protected function testClientModelRequest($body) * * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * - * @param float $number None (required) - * @param double $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param string $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) + * @param float $number None (required) + * @param double $double None (required) + * @param string $pattern_without_delimiter None (required) + * @param string $byte None (required) + * @param int $integer None (optional) + * @param int $int32 None (optional) + * @param int $int64 None (optional) + * @param float $float None (optional) + * @param string $string None (optional) + * @param string $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @param string $callback None (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1206,20 +1334,21 @@ public function testEndpointParameters($number, $double, $pattern_without_delimi * * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * - * @param float $number None (required) - * @param double $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param string $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) + * @param float $number None (required) + * @param double $double None (required) + * @param string $pattern_without_delimiter None (required) + * @param string $byte None (required) + * @param int $integer None (optional) + * @param int $int32 None (optional) + * @param int $int64 None (optional) + * @param float $float None (optional) + * @param string $string None (optional) + * @param string $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @param string $callback None (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1245,7 +1374,11 @@ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_wi if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1266,28 +1399,32 @@ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_wi * * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * - * @param float $number None (required) - * @param double $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param string $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) + * @param float $number None (required) + * @param double $double None (required) + * @param string $pattern_without_delimiter None (required) + * @param string $byte None (required) + * @param int $integer None (optional) + * @param int $int32 None (optional) + * @param int $int64 None (optional) + * @param float $float None (optional) + * @param string $string None (optional) + * @param string $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @param string $callback None (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEndpointParametersAsync($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) { - return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback)->then(function ($response) { - return $response[0]; - }); + return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1295,20 +1432,21 @@ public function testEndpointParametersAsync($number, $double, $pattern_without_d * * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * - * @param float $number None (required) - * @param double $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param string $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) + * @param float $number None (required) + * @param double $double None (required) + * @param string $pattern_without_delimiter None (required) + * @param string $byte None (required) + * @param int $integer None (optional) + * @param int $int32 None (optional) + * @param int $int64 None (optional) + * @param float $float None (optional) + * @param string $string None (optional) + * @param string $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @param string $callback None (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1317,37 +1455,47 @@ public function testEndpointParametersAsyncWithHttpInfo($number, $double, $patte $returnType = ''; $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'testEndpointParameters' * - * @param float $number None (required) - * @param double $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param string $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) + * @param float $number None (required) + * @param double $double None (required) + * @param string $pattern_without_delimiter None (required) + * @param string $byte None (required) + * @param int $integer None (optional) + * @param int $int32 None (optional) + * @param int $int64 None (optional) + * @param float $float None (optional) + * @param string $string None (optional) + * @param string $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @param string $callback None (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1355,7 +1503,9 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with { // verify the required parameter 'number' is set if ($number === null) { - throw new \InvalidArgumentException('Missing the required parameter $number when calling testEndpointParameters'); + throw new \InvalidArgumentException( + 'Missing the required parameter $number when calling testEndpointParameters' + ); } if ($number > 543.2) { throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); @@ -1366,7 +1516,9 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with // verify the required parameter 'double' is set if ($double === null) { - throw new \InvalidArgumentException('Missing the required parameter $double when calling testEndpointParameters'); + throw new \InvalidArgumentException( + 'Missing the required parameter $double when calling testEndpointParameters' + ); } if ($double > 123.4) { throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); @@ -1377,7 +1529,9 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with // verify the required parameter 'pattern_without_delimiter' is set if ($pattern_without_delimiter === null) { - throw new \InvalidArgumentException('Missing the required parameter $pattern_without_delimiter when calling testEndpointParameters'); + throw new \InvalidArgumentException( + 'Missing the required parameter $pattern_without_delimiter when calling testEndpointParameters' + ); } if (!preg_match("/^[A-Z].*_/", $pattern_without_delimiter)) { throw new \InvalidArgumentException("invalid value for \"pattern_without_delimiter\" when calling FakeApi.testEndpointParameters, must conform to the pattern /^[A-Z].*_/."); @@ -1385,7 +1539,9 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with // verify the required parameter 'byte' is set if ($byte === null) { - throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); + throw new \InvalidArgumentException( + 'Missing the required parameter $byte when calling testEndpointParameters' + ); } if ($integer !== null && $integer > 100) { throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.'); @@ -1482,6 +1638,8 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with if ($callback !== null) { $formParams['callback'] = ObjectSerializer::toFormValue($callback); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1507,13 +1665,15 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -1522,9 +1682,6 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1536,9 +1693,10 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1549,14 +1707,15 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with * * To test enum parameters * - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) - * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param double $enum_query_double Query parameter enum test (double) (optional) + * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) + * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) + * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) + * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) + * @param int $enum_query_integer Query parameter enum test (double) (optional) + * @param double $enum_query_double Query parameter enum test (double) (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1571,14 +1730,15 @@ public function testEnumParameters($enum_form_string_array = null, $enum_form_st * * To test enum parameters * - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) - * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param double $enum_query_double Query parameter enum test (double) (optional) + * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) + * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) + * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) + * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) + * @param int $enum_query_integer Query parameter enum test (double) (optional) + * @param double $enum_query_double Query parameter enum test (double) (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1604,7 +1764,11 @@ public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $ if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1625,22 +1789,26 @@ public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $ * * To test enum parameters * - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) - * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param double $enum_query_double Query parameter enum test (double) (optional) + * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) + * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) + * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) + * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) + * @param int $enum_query_integer Query parameter enum test (double) (optional) + * @param double $enum_query_double Query parameter enum test (double) (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEnumParametersAsync($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) { - return $this->testEnumParametersAsyncWithHttpInfo($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double)->then(function ($response) { - return $response[0]; - }); + return $this->testEnumParametersAsyncWithHttpInfo($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1648,14 +1816,15 @@ public function testEnumParametersAsync($enum_form_string_array = null, $enum_fo * * To test enum parameters * - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) - * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param double $enum_query_double Query parameter enum test (double) (optional) + * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) + * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) + * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) + * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) + * @param int $enum_query_integer Query parameter enum test (double) (optional) + * @param double $enum_query_double Query parameter enum test (double) (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1664,31 +1833,41 @@ public function testEnumParametersAsyncWithHttpInfo($enum_form_string_array = nu $returnType = ''; $request = $this->testEnumParametersRequest($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'testEnumParameters' * - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) - * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param double $enum_query_double Query parameter enum test (double) (optional) + * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional) + * @param string $enum_form_string Form parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) + * @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) + * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) + * @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) + * @param int $enum_query_integer Query parameter enum test (double) (optional) + * @param double $enum_query_double Query parameter enum test (double) (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1742,6 +1921,8 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en if ($enum_query_double !== null) { $formParams['enum_query_double'] = ObjectSerializer::toFormValue($enum_query_double); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1767,20 +1948,19 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1792,9 +1972,10 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1805,8 +1986,9 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en * * test json serialization of form data * - * @param string $param field1 (required) - * @param string $param2 field2 (required) + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1821,8 +2003,9 @@ public function testJsonFormData($param, $param2) * * test json serialization of form data * - * @param string $param field1 (required) - * @param string $param2 field2 (required) + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1848,7 +2031,11 @@ public function testJsonFormDataWithHttpInfo($param, $param2) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1869,16 +2056,20 @@ public function testJsonFormDataWithHttpInfo($param, $param2) * * test json serialization of form data * - * @param string $param field1 (required) - * @param string $param2 field2 (required) + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testJsonFormDataAsync($param, $param2) { - return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2)->then(function ($response) { - return $response[0]; - }); + return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1886,8 +2077,9 @@ public function testJsonFormDataAsync($param, $param2) * * test json serialization of form data * - * @param string $param field1 (required) - * @param string $param2 field2 (required) + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1896,25 +2088,35 @@ public function testJsonFormDataAsyncWithHttpInfo($param, $param2) $returnType = ''; $request = $this->testJsonFormDataRequest($param, $param2); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'testJsonFormData' * - * @param string $param field1 (required) - * @param string $param2 field2 (required) + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1922,11 +2124,15 @@ protected function testJsonFormDataRequest($param, $param2) { // verify the required parameter 'param' is set if ($param === null) { - throw new \InvalidArgumentException('Missing the required parameter $param when calling testJsonFormData'); + throw new \InvalidArgumentException( + 'Missing the required parameter $param when calling testJsonFormData' + ); } // verify the required parameter 'param2' is set if ($param2 === null) { - throw new \InvalidArgumentException('Missing the required parameter $param2 when calling testJsonFormData'); + throw new \InvalidArgumentException( + 'Missing the required parameter $param2 when calling testJsonFormData' + ); } $resourcePath = '/fake/jsonFormData'; @@ -1946,6 +2152,8 @@ protected function testJsonFormDataRequest($param, $param2) if ($param2 !== null) { $formParams['param2'] = ObjectSerializer::toFormValue($param2); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1971,20 +2179,19 @@ protected function testJsonFormDataRequest($param, $param2) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1996,9 +2203,10 @@ protected function testJsonFormDataRequest($param, $param2) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/Fake_classname_tags123Api.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/Fake_classname_tags123Api.php new file mode 100644 index 00000000000..dd25d6ae6f7 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/Fake_classname_tags123Api.php @@ -0,0 +1,341 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation testClassname + * + * To test class name in snake case + * + * @param \Swagger\Client\Model\Client $body client model (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Swagger\Client\Model\Client + */ + public function testClassname($body) + { + list($response) = $this->testClassnameWithHttpInfo($body); + return $response; + } + + /** + * Operation testClassnameWithHttpInfo + * + * To test class name in snake case + * + * @param \Swagger\Client\Model\Client $body client model (required) + * + * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) + */ + public function testClassnameWithHttpInfo($body) + { + $returnType = '\Swagger\Client\Model\Client'; + $request = $this->testClassnameRequest($body); + + try { + + try { + $response = $this->client->send($request); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Client', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation testClassnameAsync + * + * To test class name in snake case + * + * @param \Swagger\Client\Model\Client $body client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsync($body) + { + return $this->testClassnameAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testClassnameAsyncWithHttpInfo + * + * To test class name in snake case + * + * @param \Swagger\Client\Model\Client $body client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsyncWithHttpInfo($body) + { + $returnType = '\Swagger\Client\Model\Client'; + $request = $this->testClassnameRequest($body); + + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testClassname' + * + * @param \Swagger\Client\Model\Client $body client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testClassnameRequest($body) + { + // verify the required parameter 'body' is set + if ($body === null) { + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling testClassname' + ); + } + + $resourcePath = '/fake_classname_test'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers= $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('api_key_query'); + if ($apiKey !== null) { + $queryParams['api_key_query'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 989219ad924..3214d9769e2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -59,8 +59,8 @@ class PetApi /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -85,7 +85,8 @@ public function getConfig() * * Add a new pet to the store * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -100,7 +101,8 @@ public function addPet($body) * * Add a new pet to the store * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -126,7 +128,11 @@ public function addPetWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -147,15 +153,19 @@ public function addPetWithHttpInfo($body) * * Add a new pet to the store * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function addPetAsync($body) { - return $this->addPetAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->addPetAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -163,7 +173,8 @@ public function addPetAsync($body) * * Add a new pet to the store * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -172,24 +183,34 @@ public function addPetAsyncWithHttpInfo($body) $returnType = ''; $request = $this->addPetRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'addPet' * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -197,7 +218,9 @@ protected function addPetRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling addPet'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling addPet' + ); } $resourcePath = '/pet'; @@ -239,13 +262,15 @@ protected function addPetRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -254,9 +279,6 @@ protected function addPetRequest($body) $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -268,9 +290,10 @@ protected function addPetRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -281,8 +304,9 @@ protected function addPetRequest($body) * * Deletes a pet * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -297,8 +321,9 @@ public function deletePet($pet_id, $api_key = null) * * Deletes a pet * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -324,7 +349,11 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -345,16 +374,20 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null) * * Deletes a pet * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deletePetAsync($pet_id, $api_key = null) { - return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key)->then(function ($response) { - return $response[0]; - }); + return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -362,8 +395,9 @@ public function deletePetAsync($pet_id, $api_key = null) * * Deletes a pet * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -372,25 +406,35 @@ public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null) $returnType = ''; $request = $this->deletePetRequest($pet_id, $api_key); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'deletePet' * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -398,7 +442,9 @@ protected function deletePetRequest($pet_id, $api_key = null) { // verify the required parameter 'pet_id' is set if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling deletePet' + ); } $resourcePath = '/pet/{petId}'; @@ -415,9 +461,15 @@ protected function deletePetRequest($pet_id, $api_key = null) // path params if ($pet_id !== null) { - $resourcePath = str_replace('{' . 'petId' . '}', ObjectSerializer::toPathValue($pet_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -443,13 +495,15 @@ protected function deletePetRequest($pet_id, $api_key = null) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -458,9 +512,6 @@ protected function deletePetRequest($pet_id, $api_key = null) $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -472,9 +523,10 @@ protected function deletePetRequest($pet_id, $api_key = null) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'DELETE', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -485,7 +537,8 @@ protected function deletePetRequest($pet_id, $api_key = null) * * Finds Pets by status * - * @param string[] $status Status values that need to be considered for filter (required) + * @param string[] $status Status values that need to be considered for filter (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Pet[] @@ -501,7 +554,8 @@ public function findPetsByStatus($status) * * Finds Pets by status * - * @param string[] $status Status values that need to be considered for filter (required) + * @param string[] $status Status values that need to be considered for filter (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) @@ -527,7 +581,11 @@ public function findPetsByStatusWithHttpInfo($status) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -553,7 +611,11 @@ public function findPetsByStatusWithHttpInfo($status) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Pet[]', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -566,15 +628,19 @@ public function findPetsByStatusWithHttpInfo($status) * * Finds Pets by status * - * @param string[] $status Status values that need to be considered for filter (required) + * @param string[] $status Status values that need to be considered for filter (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByStatusAsync($status) { - return $this->findPetsByStatusAsyncWithHttpInfo($status)->then(function ($response) { - return $response[0]; - }); + return $this->findPetsByStatusAsyncWithHttpInfo($status) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -582,7 +648,8 @@ public function findPetsByStatusAsync($status) * * Finds Pets by status * - * @param string[] $status Status values that need to be considered for filter (required) + * @param string[] $status Status values that need to be considered for filter (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -591,38 +658,48 @@ public function findPetsByStatusAsyncWithHttpInfo($status) $returnType = '\Swagger\Client\Model\Pet[]'; $request = $this->findPetsByStatusRequest($status); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'findPetsByStatus' * - * @param string[] $status Status values that need to be considered for filter (required) + * @param string[] $status Status values that need to be considered for filter (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -630,7 +707,9 @@ protected function findPetsByStatusRequest($status) { // verify the required parameter 'status' is set if ($status === null) { - throw new \InvalidArgumentException('Missing the required parameter $status when calling findPetsByStatus'); + throw new \InvalidArgumentException( + 'Missing the required parameter $status when calling findPetsByStatus' + ); } $resourcePath = '/pet/findByStatus'; @@ -649,6 +728,8 @@ protected function findPetsByStatusRequest($status) } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -674,13 +755,15 @@ protected function findPetsByStatusRequest($status) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -689,9 +772,6 @@ protected function findPetsByStatusRequest($status) $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -703,9 +783,10 @@ protected function findPetsByStatusRequest($status) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -716,7 +797,8 @@ protected function findPetsByStatusRequest($status) * * Finds Pets by tags * - * @param string[] $tags Tags to filter by (required) + * @param string[] $tags Tags to filter by (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Pet[] @@ -732,7 +814,8 @@ public function findPetsByTags($tags) * * Finds Pets by tags * - * @param string[] $tags Tags to filter by (required) + * @param string[] $tags Tags to filter by (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) @@ -758,7 +841,11 @@ public function findPetsByTagsWithHttpInfo($tags) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -784,7 +871,11 @@ public function findPetsByTagsWithHttpInfo($tags) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Pet[]', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -797,15 +888,19 @@ public function findPetsByTagsWithHttpInfo($tags) * * Finds Pets by tags * - * @param string[] $tags Tags to filter by (required) + * @param string[] $tags Tags to filter by (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByTagsAsync($tags) { - return $this->findPetsByTagsAsyncWithHttpInfo($tags)->then(function ($response) { - return $response[0]; - }); + return $this->findPetsByTagsAsyncWithHttpInfo($tags) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -813,7 +908,8 @@ public function findPetsByTagsAsync($tags) * * Finds Pets by tags * - * @param string[] $tags Tags to filter by (required) + * @param string[] $tags Tags to filter by (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -822,38 +918,48 @@ public function findPetsByTagsAsyncWithHttpInfo($tags) $returnType = '\Swagger\Client\Model\Pet[]'; $request = $this->findPetsByTagsRequest($tags); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'findPetsByTags' * - * @param string[] $tags Tags to filter by (required) + * @param string[] $tags Tags to filter by (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -861,7 +967,9 @@ protected function findPetsByTagsRequest($tags) { // verify the required parameter 'tags' is set if ($tags === null) { - throw new \InvalidArgumentException('Missing the required parameter $tags when calling findPetsByTags'); + throw new \InvalidArgumentException( + 'Missing the required parameter $tags when calling findPetsByTags' + ); } $resourcePath = '/pet/findByTags'; @@ -880,6 +988,8 @@ protected function findPetsByTagsRequest($tags) } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -905,13 +1015,15 @@ protected function findPetsByTagsRequest($tags) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -920,9 +1032,6 @@ protected function findPetsByTagsRequest($tags) $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -934,9 +1043,10 @@ protected function findPetsByTagsRequest($tags) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -947,7 +1057,8 @@ protected function findPetsByTagsRequest($tags) * * Find pet by ID * - * @param int $pet_id ID of pet to return (required) + * @param int $pet_id ID of pet to return (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Pet @@ -963,7 +1074,8 @@ public function getPetById($pet_id) * * Find pet by ID * - * @param int $pet_id ID of pet to return (required) + * @param int $pet_id ID of pet to return (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) @@ -989,7 +1101,11 @@ public function getPetByIdWithHttpInfo($pet_id) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1015,7 +1131,11 @@ public function getPetByIdWithHttpInfo($pet_id) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Pet', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -1028,15 +1148,19 @@ public function getPetByIdWithHttpInfo($pet_id) * * Find pet by ID * - * @param int $pet_id ID of pet to return (required) + * @param int $pet_id ID of pet to return (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getPetByIdAsync($pet_id) { - return $this->getPetByIdAsyncWithHttpInfo($pet_id)->then(function ($response) { - return $response[0]; - }); + return $this->getPetByIdAsyncWithHttpInfo($pet_id) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1044,7 +1168,8 @@ public function getPetByIdAsync($pet_id) * * Find pet by ID * - * @param int $pet_id ID of pet to return (required) + * @param int $pet_id ID of pet to return (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1053,38 +1178,48 @@ public function getPetByIdAsyncWithHttpInfo($pet_id) $returnType = '\Swagger\Client\Model\Pet'; $request = $this->getPetByIdRequest($pet_id); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'getPetById' * - * @param int $pet_id ID of pet to return (required) + * @param int $pet_id ID of pet to return (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1092,7 +1227,9 @@ protected function getPetByIdRequest($pet_id) { // verify the required parameter 'pet_id' is set if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling getPetById' + ); } $resourcePath = '/pet/{petId}'; @@ -1105,9 +1242,15 @@ protected function getPetByIdRequest($pet_id) // path params if ($pet_id !== null) { - $resourcePath = str_replace('{' . 'petId' . '}', ObjectSerializer::toPathValue($pet_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1133,13 +1276,15 @@ protected function getPetByIdRequest($pet_id) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -1149,9 +1294,6 @@ protected function getPetByIdRequest($pet_id) $headers['api_key'] = $apiKey; } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1163,9 +1305,10 @@ protected function getPetByIdRequest($pet_id) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1176,7 +1319,8 @@ protected function getPetByIdRequest($pet_id) * * Update an existing pet * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1191,7 +1335,8 @@ public function updatePet($body) * * Update an existing pet * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1217,7 +1362,11 @@ public function updatePetWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1238,15 +1387,19 @@ public function updatePetWithHttpInfo($body) * * Update an existing pet * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetAsync($body) { - return $this->updatePetAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->updatePetAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1254,7 +1407,8 @@ public function updatePetAsync($body) * * Update an existing pet * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1263,24 +1417,34 @@ public function updatePetAsyncWithHttpInfo($body) $returnType = ''; $request = $this->updatePetRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'updatePet' * - * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1288,7 +1452,9 @@ protected function updatePetRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling updatePet'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling updatePet' + ); } $resourcePath = '/pet'; @@ -1330,13 +1496,15 @@ protected function updatePetRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -1345,9 +1513,6 @@ protected function updatePetRequest($body) $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1359,9 +1524,10 @@ protected function updatePetRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PUT', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1372,9 +1538,10 @@ protected function updatePetRequest($body) * * Updates a pet in the store with form data * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) + * @param int $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1389,9 +1556,10 @@ public function updatePetWithForm($pet_id, $name = null, $status = null) * * Updates a pet in the store with form data * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) + * @param int $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1417,7 +1585,11 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1438,17 +1610,21 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n * * Updates a pet in the store with form data * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) + * @param int $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetWithFormAsync($pet_id, $name = null, $status = null) { - return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status)->then(function ($response) { - return $response[0]; - }); + return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1456,9 +1632,10 @@ public function updatePetWithFormAsync($pet_id, $name = null, $status = null) * * Updates a pet in the store with form data * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) + * @param int $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1467,26 +1644,36 @@ public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $statu $returnType = ''; $request = $this->updatePetWithFormRequest($pet_id, $name, $status); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'updatePetWithForm' * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) + * @param int $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1494,7 +1681,9 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul { // verify the required parameter 'pet_id' is set if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling updatePetWithForm' + ); } $resourcePath = '/pet/{petId}'; @@ -1507,7 +1696,11 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul // path params if ($pet_id !== null) { - $resourcePath = str_replace('{' . 'petId' . '}', ObjectSerializer::toPathValue($pet_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); } // form params @@ -1518,6 +1711,8 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul if ($status !== null) { $formParams['status'] = ObjectSerializer::toFormValue($status); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1543,13 +1738,15 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -1558,9 +1755,6 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1572,9 +1766,10 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1585,9 +1780,10 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul * * uploads an image * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\ApiResponse @@ -1603,9 +1799,10 @@ public function uploadFile($pet_id, $additional_metadata = null, $file = null) * * uploads an image * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) @@ -1631,7 +1828,11 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1657,7 +1858,11 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\ApiResponse', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\ApiResponse', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -1670,17 +1875,21 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi * * uploads an image * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null) { - return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file)->then(function ($response) { - return $response[0]; - }); + return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1688,9 +1897,10 @@ public function uploadFileAsync($pet_id, $additional_metadata = null, $file = nu * * uploads an image * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1699,40 +1909,50 @@ public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null $returnType = '\Swagger\Client\Model\ApiResponse'; $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'uploadFile' * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1740,7 +1960,9 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file { // verify the required parameter 'pet_id' is set if ($pet_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); + throw new \InvalidArgumentException( + 'Missing the required parameter $pet_id when calling uploadFile' + ); } $resourcePath = '/pet/{petId}/uploadImage'; @@ -1753,7 +1975,11 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file // path params if ($pet_id !== null) { - $resourcePath = str_replace('{' . 'petId' . '}', ObjectSerializer::toPathValue($pet_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'petId' . '}', + ObjectSerializer::toPathValue($pet_id), + $resourcePath + ); } // form params @@ -1765,6 +1991,8 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file $multipart = true; $formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1790,13 +2018,15 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -1805,9 +2035,6 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1819,9 +2046,10 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 5cd336fe458..684f67f65d4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -59,8 +59,8 @@ class StoreApi /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -85,7 +85,8 @@ public function getConfig() * * Delete purchase order by ID * - * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $order_id ID of the order that needs to be deleted (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -100,7 +101,8 @@ public function deleteOrder($order_id) * * Delete purchase order by ID * - * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $order_id ID of the order that needs to be deleted (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -126,7 +128,11 @@ public function deleteOrderWithHttpInfo($order_id) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -147,15 +153,19 @@ public function deleteOrderWithHttpInfo($order_id) * * Delete purchase order by ID * - * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $order_id ID of the order that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteOrderAsync($order_id) { - return $this->deleteOrderAsyncWithHttpInfo($order_id)->then(function ($response) { - return $response[0]; - }); + return $this->deleteOrderAsyncWithHttpInfo($order_id) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -163,7 +173,8 @@ public function deleteOrderAsync($order_id) * * Delete purchase order by ID * - * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $order_id ID of the order that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -172,24 +183,34 @@ public function deleteOrderAsyncWithHttpInfo($order_id) $returnType = ''; $request = $this->deleteOrderRequest($order_id); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'deleteOrder' * - * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $order_id ID of the order that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -197,7 +218,9 @@ protected function deleteOrderRequest($order_id) { // verify the required parameter 'order_id' is set if ($order_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling deleteOrder' + ); } $resourcePath = '/store/order/{order_id}'; @@ -210,9 +233,15 @@ protected function deleteOrderRequest($order_id) // path params if ($order_id !== null) { - $resourcePath = str_replace('{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'order_id' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -238,20 +267,19 @@ protected function deleteOrderRequest($order_id) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -263,9 +291,10 @@ protected function deleteOrderRequest($order_id) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'DELETE', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -276,6 +305,7 @@ protected function deleteOrderRequest($order_id) * * Returns pet inventories by status * + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return map[string,int] @@ -291,6 +321,7 @@ public function getInventory() * * Returns pet inventories by status * + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of map[string,int], HTTP status code, HTTP response headers (array of strings) @@ -316,7 +347,11 @@ public function getInventoryWithHttpInfo() if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -342,7 +377,11 @@ public function getInventoryWithHttpInfo() } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), 'map[string,int]', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'map[string,int]', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -355,14 +394,18 @@ public function getInventoryWithHttpInfo() * * Returns pet inventories by status * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getInventoryAsync() { - return $this->getInventoryAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); + return $this->getInventoryAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -370,6 +413,7 @@ public function getInventoryAsync() * * Returns pet inventories by status * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -378,37 +422,47 @@ public function getInventoryAsyncWithHttpInfo() $returnType = 'map[string,int]'; $request = $this->getInventoryRequest(); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'getInventory' * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -424,6 +478,8 @@ protected function getInventoryRequest() + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -449,13 +505,15 @@ protected function getInventoryRequest() 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } @@ -465,9 +523,6 @@ protected function getInventoryRequest() $headers['api_key'] = $apiKey; } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -479,9 +534,10 @@ protected function getInventoryRequest() $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -492,7 +548,8 @@ protected function getInventoryRequest() * * Find purchase order by ID * - * @param int $order_id ID of pet that needs to be fetched (required) + * @param int $order_id ID of pet that needs to be fetched (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Order @@ -508,7 +565,8 @@ public function getOrderById($order_id) * * Find purchase order by ID * - * @param int $order_id ID of pet that needs to be fetched (required) + * @param int $order_id ID of pet that needs to be fetched (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) @@ -534,7 +592,11 @@ public function getOrderByIdWithHttpInfo($order_id) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -560,7 +622,11 @@ public function getOrderByIdWithHttpInfo($order_id) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Order', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -573,15 +639,19 @@ public function getOrderByIdWithHttpInfo($order_id) * * Find purchase order by ID * - * @param int $order_id ID of pet that needs to be fetched (required) + * @param int $order_id ID of pet that needs to be fetched (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getOrderByIdAsync($order_id) { - return $this->getOrderByIdAsyncWithHttpInfo($order_id)->then(function ($response) { - return $response[0]; - }); + return $this->getOrderByIdAsyncWithHttpInfo($order_id) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -589,7 +659,8 @@ public function getOrderByIdAsync($order_id) * * Find purchase order by ID * - * @param int $order_id ID of pet that needs to be fetched (required) + * @param int $order_id ID of pet that needs to be fetched (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -598,38 +669,48 @@ public function getOrderByIdAsyncWithHttpInfo($order_id) $returnType = '\Swagger\Client\Model\Order'; $request = $this->getOrderByIdRequest($order_id); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'getOrderById' * - * @param int $order_id ID of pet that needs to be fetched (required) + * @param int $order_id ID of pet that needs to be fetched (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -637,7 +718,9 @@ protected function getOrderByIdRequest($order_id) { // verify the required parameter 'order_id' is set if ($order_id === null) { - throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById'); + throw new \InvalidArgumentException( + 'Missing the required parameter $order_id when calling getOrderById' + ); } if ($order_id > 5) { throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be smaller than or equal to 5.'); @@ -657,9 +740,15 @@ protected function getOrderByIdRequest($order_id) // path params if ($order_id !== null) { - $resourcePath = str_replace('{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath); + $resourcePath = str_replace( + '{' . 'order_id' . '}', + ObjectSerializer::toPathValue($order_id), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -685,20 +774,19 @@ protected function getOrderByIdRequest($order_id) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -710,9 +798,10 @@ protected function getOrderByIdRequest($order_id) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -723,7 +812,8 @@ protected function getOrderByIdRequest($order_id) * * Place an order for a pet * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\Order @@ -739,7 +829,8 @@ public function placeOrder($body) * * Place an order for a pet * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) @@ -765,7 +856,11 @@ public function placeOrderWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -791,7 +886,11 @@ public function placeOrderWithHttpInfo($body) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\Order', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -804,15 +903,19 @@ public function placeOrderWithHttpInfo($body) * * Place an order for a pet * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function placeOrderAsync($body) { - return $this->placeOrderAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->placeOrderAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -820,7 +923,8 @@ public function placeOrderAsync($body) * * Place an order for a pet * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -829,38 +933,48 @@ public function placeOrderAsyncWithHttpInfo($body) $returnType = '\Swagger\Client\Model\Order'; $request = $this->placeOrderRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'placeOrder' * - * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -868,7 +982,9 @@ protected function placeOrderRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling placeOrder' + ); } $resourcePath = '/store/order'; @@ -910,20 +1026,19 @@ protected function placeOrderRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -935,9 +1050,10 @@ protected function placeOrderRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 321aa41ac75..b2517fd4479 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -59,8 +59,8 @@ class UserApi /** * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector + * @param Configuration $config + * @param HeaderSelector $selector */ public function __construct( ClientInterface $client = null, @@ -85,7 +85,8 @@ public function getConfig() * * Create user * - * @param \Swagger\Client\Model\User $body Created user object (required) + * @param \Swagger\Client\Model\User $body Created user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -100,7 +101,8 @@ public function createUser($body) * * Create user * - * @param \Swagger\Client\Model\User $body Created user object (required) + * @param \Swagger\Client\Model\User $body Created user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -126,7 +128,11 @@ public function createUserWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -147,15 +153,19 @@ public function createUserWithHttpInfo($body) * * Create user * - * @param \Swagger\Client\Model\User $body Created user object (required) + * @param \Swagger\Client\Model\User $body Created user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUserAsync($body) { - return $this->createUserAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->createUserAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -163,7 +173,8 @@ public function createUserAsync($body) * * Create user * - * @param \Swagger\Client\Model\User $body Created user object (required) + * @param \Swagger\Client\Model\User $body Created user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -172,24 +183,34 @@ public function createUserAsyncWithHttpInfo($body) $returnType = ''; $request = $this->createUserRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'createUser' * - * @param \Swagger\Client\Model\User $body Created user object (required) + * @param \Swagger\Client\Model\User $body Created user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -197,7 +218,9 @@ protected function createUserRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling createUser' + ); } $resourcePath = '/user'; @@ -239,20 +262,19 @@ protected function createUserRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -264,9 +286,10 @@ protected function createUserRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -277,7 +300,8 @@ protected function createUserRequest($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -292,7 +316,8 @@ public function createUsersWithArrayInput($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -318,7 +343,11 @@ public function createUsersWithArrayInputWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -339,15 +368,19 @@ public function createUsersWithArrayInputWithHttpInfo($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithArrayInputAsync($body) { - return $this->createUsersWithArrayInputAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->createUsersWithArrayInputAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -355,7 +388,8 @@ public function createUsersWithArrayInputAsync($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -364,24 +398,34 @@ public function createUsersWithArrayInputAsyncWithHttpInfo($body) $returnType = ''; $request = $this->createUsersWithArrayInputRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'createUsersWithArrayInput' * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -389,7 +433,9 @@ protected function createUsersWithArrayInputRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithArrayInput'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling createUsersWithArrayInput' + ); } $resourcePath = '/user/createWithArray'; @@ -431,20 +477,19 @@ protected function createUsersWithArrayInputRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -456,9 +501,10 @@ protected function createUsersWithArrayInputRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -469,7 +515,8 @@ protected function createUsersWithArrayInputRequest($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -484,7 +531,8 @@ public function createUsersWithListInput($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -510,7 +558,11 @@ public function createUsersWithListInputWithHttpInfo($body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -531,15 +583,19 @@ public function createUsersWithListInputWithHttpInfo($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithListInputAsync($body) { - return $this->createUsersWithListInputAsyncWithHttpInfo($body)->then(function ($response) { - return $response[0]; - }); + return $this->createUsersWithListInputAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -547,7 +603,8 @@ public function createUsersWithListInputAsync($body) * * Creates list of users with given input array * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -556,24 +613,34 @@ public function createUsersWithListInputAsyncWithHttpInfo($body) $returnType = ''; $request = $this->createUsersWithListInputRequest($body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'createUsersWithListInput' * - * @param \Swagger\Client\Model\User[] $body List of user object (required) + * @param \Swagger\Client\Model\User[] $body List of user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -581,7 +648,9 @@ protected function createUsersWithListInputRequest($body) { // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithListInput'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling createUsersWithListInput' + ); } $resourcePath = '/user/createWithList'; @@ -623,20 +692,19 @@ protected function createUsersWithListInputRequest($body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -648,9 +716,10 @@ protected function createUsersWithListInputRequest($body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -661,7 +730,8 @@ protected function createUsersWithListInputRequest($body) * * Delete user * - * @param string $username The name that needs to be deleted (required) + * @param string $username The name that needs to be deleted (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -676,7 +746,8 @@ public function deleteUser($username) * * Delete user * - * @param string $username The name that needs to be deleted (required) + * @param string $username The name that needs to be deleted (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -702,7 +773,11 @@ public function deleteUserWithHttpInfo($username) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -723,15 +798,19 @@ public function deleteUserWithHttpInfo($username) * * Delete user * - * @param string $username The name that needs to be deleted (required) + * @param string $username The name that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteUserAsync($username) { - return $this->deleteUserAsyncWithHttpInfo($username)->then(function ($response) { - return $response[0]; - }); + return $this->deleteUserAsyncWithHttpInfo($username) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -739,7 +818,8 @@ public function deleteUserAsync($username) * * Delete user * - * @param string $username The name that needs to be deleted (required) + * @param string $username The name that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -748,24 +828,34 @@ public function deleteUserAsyncWithHttpInfo($username) $returnType = ''; $request = $this->deleteUserRequest($username); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'deleteUser' * - * @param string $username The name that needs to be deleted (required) + * @param string $username The name that needs to be deleted (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -773,7 +863,9 @@ protected function deleteUserRequest($username) { // verify the required parameter 'username' is set if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $username when calling deleteUser' + ); } $resourcePath = '/user/{username}'; @@ -786,9 +878,15 @@ protected function deleteUserRequest($username) // path params if ($username !== null) { - $resourcePath = str_replace('{' . 'username' . '}', ObjectSerializer::toPathValue($username), $resourcePath); + $resourcePath = str_replace( + '{' . 'username' . '}', + ObjectSerializer::toPathValue($username), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -814,20 +912,19 @@ protected function deleteUserRequest($username) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -839,9 +936,10 @@ protected function deleteUserRequest($username) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'DELETE', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -852,7 +950,8 @@ protected function deleteUserRequest($username) * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \Swagger\Client\Model\User @@ -868,7 +967,8 @@ public function getUserByName($username) * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) @@ -894,7 +994,11 @@ public function getUserByNameWithHttpInfo($username) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -920,7 +1024,11 @@ public function getUserByNameWithHttpInfo($username) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\User', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Swagger\Client\Model\User', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -933,15 +1041,19 @@ public function getUserByNameWithHttpInfo($username) * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getUserByNameAsync($username) { - return $this->getUserByNameAsyncWithHttpInfo($username)->then(function ($response) { - return $response[0]; - }); + return $this->getUserByNameAsyncWithHttpInfo($username) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -949,7 +1061,8 @@ public function getUserByNameAsync($username) * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -958,38 +1071,48 @@ public function getUserByNameAsyncWithHttpInfo($username) $returnType = '\Swagger\Client\Model\User'; $request = $this->getUserByNameRequest($username); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'getUserByName' * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -997,7 +1120,9 @@ protected function getUserByNameRequest($username) { // verify the required parameter 'username' is set if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); + throw new \InvalidArgumentException( + 'Missing the required parameter $username when calling getUserByName' + ); } $resourcePath = '/user/{username}'; @@ -1010,9 +1135,15 @@ protected function getUserByNameRequest($username) // path params if ($username !== null) { - $resourcePath = str_replace('{' . 'username' . '}', ObjectSerializer::toPathValue($username), $resourcePath); + $resourcePath = str_replace( + '{' . 'username' . '}', + ObjectSerializer::toPathValue($username), + $resourcePath + ); } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1038,20 +1169,19 @@ protected function getUserByNameRequest($username) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1063,9 +1193,10 @@ protected function getUserByNameRequest($username) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1076,8 +1207,9 @@ protected function getUserByNameRequest($username) * * Logs user into the system * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return string @@ -1093,8 +1225,9 @@ public function loginUser($username, $password) * * Logs user into the system * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) @@ -1120,7 +1253,11 @@ public function loginUserWithHttpInfo($username, $password) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1146,7 +1283,11 @@ public function loginUserWithHttpInfo($username, $password) } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + 'string', + $e->getResponseHeaders() + ); $e->setResponseObject($data); break; } @@ -1159,16 +1300,20 @@ public function loginUserWithHttpInfo($username, $password) * * Logs user into the system * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function loginUserAsync($username, $password) { - return $this->loginUserAsyncWithHttpInfo($username, $password)->then(function ($response) { - return $response[0]; - }); + return $this->loginUserAsyncWithHttpInfo($username, $password) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1176,8 +1321,9 @@ public function loginUserAsync($username, $password) * * Logs user into the system * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1186,39 +1332,49 @@ public function loginUserAsyncWithHttpInfo($username, $password) $returnType = 'string'; $request = $this->loginUserRequest($username, $password); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - $responseBody = $response->getBody(); - if ($returnType === '\SplFileObject') { - $content = $responseBody; //stream goes to serializer - } else { - $content = $responseBody->getContents(); - if ($returnType !== 'string') { - $content = json_decode($content); + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() ); - }); } /** * Create request for operation 'loginUser' * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1226,11 +1382,15 @@ protected function loginUserRequest($username, $password) { // verify the required parameter 'username' is set if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling loginUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $username when calling loginUser' + ); } // verify the required parameter 'password' is set if ($password === null) { - throw new \InvalidArgumentException('Missing the required parameter $password when calling loginUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $password when calling loginUser' + ); } $resourcePath = '/user/login'; @@ -1250,6 +1410,8 @@ protected function loginUserRequest($username, $password) } + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1275,20 +1437,19 @@ protected function loginUserRequest($username, $password) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1300,9 +1461,10 @@ protected function loginUserRequest($username, $password) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1313,6 +1475,7 @@ protected function loginUserRequest($username, $password) * * Logs out current logged in user session * + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1327,6 +1490,7 @@ public function logoutUser() * * Logs out current logged in user session * + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1352,7 +1516,11 @@ public function logoutUserWithHttpInfo() if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1373,14 +1541,18 @@ public function logoutUserWithHttpInfo() * * Logs out current logged in user session * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function logoutUserAsync() { - return $this->logoutUserAsyncWithHttpInfo()->then(function ($response) { - return $response[0]; - }); + return $this->logoutUserAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1388,6 +1560,7 @@ public function logoutUserAsync() * * Logs out current logged in user session * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1396,23 +1569,33 @@ public function logoutUserAsyncWithHttpInfo() $returnType = ''; $request = $this->logoutUserRequest(); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'logoutUser' * + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1428,6 +1611,8 @@ protected function logoutUserRequest() + // body params + $_tempBody = null; if ($multipart) { $headers= $this->headerSelector->selectHeadersForMultipart( @@ -1453,20 +1638,19 @@ protected function logoutUserRequest() 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1478,9 +1662,10 @@ protected function logoutUserRequest() $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'GET', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1491,8 +1676,9 @@ protected function logoutUserRequest() * * Updated user * - * @param string $username name that need to be deleted (required) - * @param \Swagger\Client\Model\User $body Updated user object (required) + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void @@ -1507,8 +1693,9 @@ public function updateUser($username, $body) * * Updated user * - * @param string $username name that need to be deleted (required) - * @param \Swagger\Client\Model\User $body Updated user object (required) + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (required) + * * @throws \Swagger\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) @@ -1534,7 +1721,11 @@ public function updateUserWithHttpInfo($username, $body) if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( - "[$statusCode] Error connecting to the API ({$request->getUri()})", + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), $statusCode, $response->getHeaders(), $response->getBody() @@ -1555,16 +1746,20 @@ public function updateUserWithHttpInfo($username, $body) * * Updated user * - * @param string $username name that need to be deleted (required) - * @param \Swagger\Client\Model\User $body Updated user object (required) + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateUserAsync($username, $body) { - return $this->updateUserAsyncWithHttpInfo($username, $body)->then(function ($response) { - return $response[0]; - }); + return $this->updateUserAsyncWithHttpInfo($username, $body) + ->then( + function ($response) { + return $response[0]; + } + ); } /** @@ -1572,8 +1767,9 @@ public function updateUserAsync($username, $body) * * Updated user * - * @param string $username name that need to be deleted (required) - * @param \Swagger\Client\Model\User $body Updated user object (required) + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ @@ -1582,25 +1778,35 @@ public function updateUserAsyncWithHttpInfo($username, $body) $returnType = ''; $request = $this->updateUserRequest($username, $body); - return $this->client->sendAsync($request)->then(function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - "[$statusCode] Error connecting to the API ({$exception->getRequest()->getUri()})", - $statusCode, - $response->getHeaders(), - $response->getBody() + return $this->client + ->sendAsync($request) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } ); - }); } /** * Create request for operation 'updateUser' * - * @param string $username name that need to be deleted (required) - * @param \Swagger\Client\Model\User $body Updated user object (required) + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (required) + * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ @@ -1608,11 +1814,15 @@ protected function updateUserRequest($username, $body) { // verify the required parameter 'username' is set if ($username === null) { - throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $username when calling updateUser' + ); } // verify the required parameter 'body' is set if ($body === null) { - throw new \InvalidArgumentException('Missing the required parameter $body when calling updateUser'); + throw new \InvalidArgumentException( + 'Missing the required parameter $body when calling updateUser' + ); } $resourcePath = '/user/{username}'; @@ -1625,7 +1835,11 @@ protected function updateUserRequest($username, $body) // path params if ($username !== null) { - $resourcePath = str_replace('{' . 'username' . '}', ObjectSerializer::toPathValue($username), $resourcePath); + $resourcePath = str_replace( + '{' . 'username' . '}', + ObjectSerializer::toPathValue($username), + $resourcePath + ); } // body params @@ -1658,20 +1872,19 @@ protected function updateUserRequest($username, $body) 'contents' => $formParamValue ]; } - $httpBody = new MultipartStream($multipartContents); // for HTTP post (form) + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { - $httpBody = \GuzzleHttp\Psr7\build_query($formParams); // for HTTP post (form) + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } - $query = \GuzzleHttp\Psr7\build_query($queryParams); - $url = $this->config->getHost() . $resourcePath . ($query ? '?' . $query : ''); - $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); @@ -1683,9 +1896,10 @@ protected function updateUserRequest($username, $body) $headers ); + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PUT', - $url, + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/Fake_classname_tags123ApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/Fake_classname_tags123ApiTest.php new file mode 100644 index 00000000000..b9b64aeca97 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/Fake_classname_tags123ApiTest.php @@ -0,0 +1,83 @@ +