[PHP] Improve Api template (#6507)

* Improve spacing in doc comment

* Improve grouping of parameter tags

* Improve line length

* Fix undefined variable $_tempBody

* Improve indent
This commit is contained in:
Akihito Nakano
2017-09-24 16:40:06 +09:00
committed by wing328
parent ac99fe6b2d
commit b31a80448a
12 changed files with 2560 additions and 1232 deletions
@@ -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(
"[$statusCode] Error connecting to the API ({$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(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$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
);
@@ -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 @@ class FakeApi
*
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
*
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
*
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return void
@@ -100,7 +101,8 @@ class FakeApi
*
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
*
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;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 @@ class FakeApi
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 @@ class FakeApi
*
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
*
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;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 @@ class FakeApi
*
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
*
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
@@ -172,24 +183,34 @@ class FakeApi
$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 *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
* @param string $test_code_inject____end____rn_n_r To test code injection *_/ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r (optional)
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
@@ -209,6 +230,8 @@ class FakeApi
if ($test_code_inject____end____rn_n_r !== null) {
$formParams['test code inject */ &#39; &quot; &#x3D;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 @@ class FakeApi
'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 @@ class FakeApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PUT',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
@@ -56,14 +56,14 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\AnotherFakeApi();
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
$api_instance = new Swagger\Client\Api\FakeApi();
$body = new \Swagger\Client\Model\OuterBoolean(); // \Swagger\Client\Model\OuterBoolean | Input boolean as post body
try {
$result = $api_instance->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
@@ -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
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\AnotherFakeApi(new \Http\Adapter\Guzzle6\Client());
$api_instance = new Swagger\Client\Api\AnotherfakeApi(new \Http\Adapter\Guzzle6\Client());
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
try {
$result = $api_instance->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;
}
?>
```
@@ -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
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: api_key_query
Swagger\Client\Configuration::getDefaultConfiguration()->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)
@@ -1,6 +1,6 @@
<?php
/**
* AnotherFakeApi
* AnotherfakeApi
* PHP version 5
*
* @category Class
@@ -39,14 +39,14 @@ use Swagger\Client\HeaderSelector;
use Swagger\Client\ObjectSerializer;
/**
* AnotherFakeApi Class Doc Comment
* AnotherfakeApi Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class AnotherFakeApi
class AnotherfakeApi
{
/**
* @var ClientInterface
@@ -60,8 +60,8 @@ class AnotherFakeApi
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
* @param Configuration $config
* @param HeaderSelector $selector
*/
public function __construct(
ClientInterface $client = null,
@@ -86,7 +86,8 @@ class AnotherFakeApi
*
* To test special tags
*
* @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
@@ -102,7 +103,8 @@ class AnotherFakeApi
*
* To test special tags
*
* @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)
@@ -128,7 +130,11 @@ class AnotherFakeApi
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()
@@ -154,7 +160,11 @@ class AnotherFakeApi
} 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 @@ class AnotherFakeApi
*
* 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 @@ class AnotherFakeApi
*
* 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 @@ class AnotherFakeApi
$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(
"[$statusCode] Error connecting to the API ({$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(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$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 @@ class AnotherFakeApi
{
// 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 @@ class AnotherFakeApi
'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 @@ class AnotherFakeApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'PATCH',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,341 @@
<?php
/**
* Fake_classname_tags123Api
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Swagger Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Api;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use Swagger\Client\ApiException;
use Swagger\Client\Configuration;
use Swagger\Client\HeaderSelector;
use Swagger\Client\ObjectSerializer;
/**
* Fake_classname_tags123Api Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class Fake_classname_tags123Api
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $selector
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null
) {
$this->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
);
}
}
File diff suppressed because it is too large Load Diff
@@ -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 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
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 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
$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 @@ class StoreApi
{
// 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 @@ class StoreApi
// 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 @@ class StoreApi
'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 @@ class StoreApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'DELETE',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
@@ -276,6 +305,7 @@ class StoreApi
*
* Returns pet inventories by status
*
*
* @throws \Swagger\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return map[string,int]
@@ -291,6 +321,7 @@ class StoreApi
*
* 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 @@ class StoreApi
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 @@ class StoreApi
} 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 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* Returns pet inventories by status
*
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
@@ -378,37 +422,47 @@ class StoreApi
$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(
"[$statusCode] Error connecting to the API ({$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(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
);
}
);
});
}
/**
* Create request for operation 'getInventory'
*
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
@@ -424,6 +478,8 @@ class StoreApi
// body params
$_tempBody = null;
if ($multipart) {
$headers= $this->headerSelector->selectHeadersForMultipart(
@@ -449,13 +505,15 @@ class StoreApi
'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 @@ class StoreApi
$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 @@ class StoreApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
@@ -492,7 +548,8 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
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 @@ class StoreApi
} 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 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
$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(
"[$statusCode] Error connecting to the API ({$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(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$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 @@ class StoreApi
{
// 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 @@ class StoreApi
// 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 @@ class StoreApi
'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 @@ class StoreApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'GET',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
@@ -723,7 +812,8 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
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 @@ class StoreApi
} 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 @@ class StoreApi
*
* 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 @@ class StoreApi
*
* 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 @@ class StoreApi
$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(
"[$statusCode] Error connecting to the API ({$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(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$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 @@ class StoreApi
{
// 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 @@ class StoreApi
'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 @@ class StoreApi
$headers
);
$query = \GuzzleHttp\Psr7\build_query($queryParams);
return new Request(
'POST',
$url,
$this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,83 @@
<?php
/**
* Fake_classname_tags123ApiTest
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Swagger Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the endpoint.
*/
namespace Swagger\Client;
use \Swagger\Client\Configuration;
use \Swagger\Client\ApiException;
use \Swagger\Client\ObjectSerializer;
/**
* Fake_classname_tags123ApiTest Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @author Swagger Codegen team
* @link https://github.com/swagger-api/swagger-codegen
*/
class Fake_classname_tags123ApiTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running any test cases
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test case for testClassname
*
* To test class name in snake case.
*
*/
public function testTestClassname()
{
}
}