From fbde7f88eea846f4fdc69df9fb7394f5e88bd1e2 Mon Sep 17 00:00:00 2001 From: abcsun Date: Thu, 28 Apr 2016 10:39:54 +0800 Subject: [PATCH 1/2] add parameter validation in methord call --- .../src/main/resources/php/api.mustache | 61 +++- .../petstore/php/SwaggerClient-php/README.md | 25 +- .../php/SwaggerClient-php/docs/FakeApi.md | 75 +++++ .../php/SwaggerClient-php/lib/Api/FakeApi.php | 308 ++++++++++++++++++ .../php/SwaggerClient-php/lib/Api/PetApi.php | 32 +- .../SwaggerClient-php/lib/Api/StoreApi.php | 26 +- .../php/SwaggerClient-php/lib/Api/UserApi.php | 33 +- .../lib/Tests/FakeApiTest.php | 76 +++++ .../lib/Tests/FormatTestTest.php | 70 ++++ 9 files changed, 658 insertions(+), 48 deletions(-) create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/FakeApi.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Tests/FakeApiTest.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Tests/FormatTestTest.php diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 2692ba66f9..c31eff8bc4 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -122,7 +122,36 @@ use \{{invokerPackage}}\ObjectSerializer; // verify the required parameter '{{paramName}}' is set if (${{paramName}} === null) { throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); - }{{/required}}{{/allParams}} + } + {{#hasValidation}} + {{#maxLength}} + if (strlen(${{paramName}}) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen(${{paramName}}) > {{minLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if (${{paramName}} > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if (${{paramName}} < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", ${{paramName}})) { + throw new \InvalidArgumentException('invalid value for "{{paramName}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + + {{/hasValidation}} + {{/required}}{{/allParams}} // parse inputs $resourcePath = "{{path}}"; @@ -172,6 +201,33 @@ use \{{invokerPackage}}\ObjectSerializer; {{#formParams}}// form params if (${{paramName}} !== null) { + {{#hasValidation}} + {{#maxLength}} + if (strlen(${{paramName}}) > {{maxLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); + } + {{/maxLength}} + {{#minLength}} + if (strlen(${{paramName}}) > {{minLength}}) { + throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); + } + {{/minLength}} + {{#maximum}} + if (${{paramName}} > {{maximum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); + } + {{/maximum}} + {{#minimum}} + if (${{paramName}} < {{minimum}}) { + throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); + } + {{/minimum}} + {{#pattern}} + if (!preg_match("{{pattern}}", ${{paramName}})) { + throw new \InvalidArgumentException('invalid value for "{{paramName}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); + } + {{/pattern}} + {{/hasValidation}} {{#isFile}} // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload @@ -184,7 +240,8 @@ use \{{invokerPackage}}\ObjectSerializer; {{^isFile}} $formParams['{{baseName}}'] = $this->apiClient->getSerializer()->toFormValue(${{paramName}}); {{/isFile}} - }{{/formParams}} + } + {{/formParams}} {{#bodyParams}}// body params $_tempBody = null; if (isset(${{paramName}})) { diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 80e8d1bae7..aa6ce69b76 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-23T22:48:00.795+08:00 +- Build date: 2016-04-28T02:26:28.980Z - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -58,16 +58,24 @@ Please follow the [installation procedure](#installation--usage) and then run th setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(); -$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store +$api_instance = new Swagger\Client\Api\FakeApi(); +$number = "number_example"; // string | None +$double = 1.2; // double | None +$string = "string_example"; // string | None +$byte = "B"; // string | None +$integer = 56; // int | None +$int32 = 56; // int | None +$int64 = 789; // int | None +$float = 3.4; // float | None +$binary = "B"; // string | None +$date = new \DateTime(); // \DateTime | None +$date_time = new \DateTime(); // \DateTime | None +$password = "password_example"; // string | None try { - $api_instance->addPet($body); + $api_instance->testEndpointParameters($number, $double, $string, $byte, $integer, $int32, $int64, $float, $binary, $date, $date_time, $password); } catch (Exception $e) { - echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), "\n"; + echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), "\n"; } ?> @@ -79,6 +87,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters *PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/FakeApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/FakeApi.md new file mode 100644 index 0000000000..bc47365c9e --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/FakeApi.md @@ -0,0 +1,75 @@ +# Swagger\Client\FakeApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters + + +# **testEndpointParameters** +> testEndpointParameters($number, $double, $string, $byte, $integer, $int32, $int64, $float, $binary, $date, $date_time, $password) + +Fake endpoint for testing various parameters + +Fake endpoint for testing various parameters + +### Example +```php +testEndpointParameters($number, $double, $string, $byte, $integer, $int32, $int64, $float, $binary, $date, $date_time, $password); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), "\n"; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **string**| None | + **double** | **double**| None | + **string** | **string**| None | + **byte** | **string**| None | + **integer** | **int**| None | [optional] + **int32** | **int**| None | [optional] + **int64** | **int**| None | [optional] + **float** | **float**| None | [optional] + **binary** | **string**| None | [optional] + **date** | **\DateTime**| None | [optional] + **date_time** | **\DateTime**| None | [optional] + **password** | **string**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, 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/FakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php new file mode 100644 index 0000000000..f6f2e73950 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -0,0 +1,308 @@ +getConfig()->setHost('http://petstore.swagger.io/v2'); + } + + $this->apiClient = $apiClient; + } + + /** + * Get API client + * @return \Swagger\Client\ApiClient get the API client + */ + public function getApiClient() + { + return $this->apiClient; + } + + /** + * Set the API client + * @param \Swagger\Client\ApiClient $apiClient set the API client + * @return FakeApi + */ + public function setApiClient(ApiClient $apiClient) + { + $this->apiClient = $apiClient; + return $this; + } + + /** + * testEndpointParameters + * + * Fake endpoint for testing various parameters + * + * @param string $number None (required) + * @param double $double None (required) + * @param string $string 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 $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function testEndpointParameters($number, $double, $string, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $binary = null, $date = null, $date_time = null, $password = null) + { + list($response) = $this->testEndpointParametersWithHttpInfo ($number, $double, $string, $byte, $integer, $int32, $int64, $float, $binary, $date, $date_time, $password); + return $response; + } + + + /** + * testEndpointParametersWithHttpInfo + * + * Fake endpoint for testing various parameters + * + * @param string $number None (required) + * @param double $double None (required) + * @param string $string 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 $binary None (optional) + * @param \DateTime $date None (optional) + * @param \DateTime $date_time None (optional) + * @param string $password None (optional) + * @return Array of null, HTTP status code, HTTP response headers (array of strings) + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function testEndpointParametersWithHttpInfo($number, $double, $string, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $binary = null, $date = null, $date_time = null, $password = null) + { + + // verify the required parameter 'number' is set + if ($number === null) { + 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.'); + } + if ($number < 32.1) { + throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); + } + + + // verify the required parameter 'double' is set + if ($double === null) { + 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.'); + } + if ($double < 67.8) { + throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); + } + + + // verify the required parameter 'string' is set + if ($string === null) { + throw new \InvalidArgumentException('Missing the required parameter $string when calling testEndpointParameters'); + } + if (!preg_match("/[a-z]/i", $string)) { + throw new \InvalidArgumentException('invalid value for "string" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); + } + + + // verify the required parameter 'byte' is set + if ($byte === null) { + throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); + } + + + // parse inputs + $resourcePath = "/fake"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/xml', 'application/json')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + // default format to json + $resourcePath = str_replace("{format}", "json", $resourcePath); + + // form params + if ($integer !== null) { + if ($integer > 100.0) { + throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); + } + if ($integer < 10.0) { + throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); + } + $formParams['integer'] = $this->apiClient->getSerializer()->toFormValue($integer); + } +// form params + if ($int32 !== null) { + if ($int32 > 200.0) { + throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); + } + if ($int32 < 20.0) { + throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); + } + $formParams['int32'] = $this->apiClient->getSerializer()->toFormValue($int32); + } +// form params + if ($int64 !== null) { + $formParams['int64'] = $this->apiClient->getSerializer()->toFormValue($int64); + } +// form params + if ($number !== null) { + if ($number > 543.2) { + throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); + } + if ($number < 32.1) { + throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); + } + $formParams['number'] = $this->apiClient->getSerializer()->toFormValue($number); + } +// form params + if ($float !== null) { + if ($float > 987.6) { + throw new \InvalidArgumentException('invalid value for "$float" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); + } + $formParams['float'] = $this->apiClient->getSerializer()->toFormValue($float); + } +// form params + if ($double !== null) { + if ($double > 123.4) { + throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); + } + if ($double < 67.8) { + throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); + } + $formParams['double'] = $this->apiClient->getSerializer()->toFormValue($double); + } +// form params + if ($string !== null) { + if (!preg_match("/[a-z]/i", $string)) { + throw new \InvalidArgumentException('invalid value for "string" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); + } + $formParams['string'] = $this->apiClient->getSerializer()->toFormValue($string); + } +// form params + if ($byte !== null) { + $formParams['byte'] = $this->apiClient->getSerializer()->toFormValue($byte); + } +// form params + if ($binary !== null) { + $formParams['binary'] = $this->apiClient->getSerializer()->toFormValue($binary); + } +// form params + if ($date !== null) { + $formParams['date'] = $this->apiClient->getSerializer()->toFormValue($date); + } +// form params + if ($date_time !== null) { + $formParams['dateTime'] = $this->apiClient->getSerializer()->toFormValue($date_time); + } +// form params + if ($password !== null) { + if (strlen($password) > 64) { + throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); + } + if (strlen($password) > 10) { + throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); + } + $formParams['password'] = $this->apiClient->getSerializer()->toFormValue($password); + } + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } elseif (count($formParams) > 0) { + $httpBody = $formParams; // for HTTP post (form) + } + // make the API Call + try { + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( + $resourcePath, 'POST', + $queryParams, $httpBody, + $headerParams + ); + + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { + switch ($e->getCode()) { + } + + throw $e; + } + } +} 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 1154b72929..fff4e6be41 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -122,6 +122,7 @@ class PetApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling addPet'); } + // parse inputs $resourcePath = "/pet"; @@ -141,8 +142,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -209,6 +209,7 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -238,8 +239,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -300,6 +300,7 @@ class PetApi if ($status === null) { throw new \InvalidArgumentException('Missing the required parameter $status when calling findPetsByStatus'); } + // parse inputs $resourcePath = "/pet/findByStatus"; @@ -325,8 +326,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -394,6 +394,7 @@ class PetApi if ($tags === null) { throw new \InvalidArgumentException('Missing the required parameter $tags when calling findPetsByTags'); } + // parse inputs $resourcePath = "/pet/findByTags"; @@ -419,8 +420,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -488,6 +488,7 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -514,8 +515,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -585,6 +585,7 @@ class PetApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling updatePet'); } + // parse inputs $resourcePath = "/pet"; @@ -604,8 +605,7 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -674,6 +674,7 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); } + // parse inputs $resourcePath = "/pet/{petId}"; @@ -703,7 +704,8 @@ class PetApi // form params if ($name !== null) { $formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name); - }// form params + } +// form params if ($status !== null) { $formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status); } @@ -772,6 +774,7 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); } + // parse inputs $resourcePath = "/pet/{petId}/uploadImage"; @@ -801,7 +804,8 @@ class PetApi // form params if ($additional_metadata !== null) { $formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata); - }// form params + } +// form params if ($file !== null) { // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload 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 e5bf83b446..77d5b9ecba 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -122,6 +122,11 @@ class StoreApi if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); } + if ($order_id < 1.0) { + throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.deleteOrder, must be bigger than or equal to 1.0.'); + } + + // parse inputs $resourcePath = "/store/order/{orderId}"; @@ -148,8 +153,7 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -218,8 +222,7 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -289,6 +292,14 @@ class StoreApi if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById'); } + if ($order_id > 5.0) { + throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be smaller than or equal to 5.0.'); + } + if ($order_id < 1.0) { + throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be bigger than or equal to 1.0.'); + } + + // parse inputs $resourcePath = "/store/order/{orderId}"; @@ -315,8 +326,7 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -379,6 +389,7 @@ class StoreApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); } + // parse inputs $resourcePath = "/store/order"; @@ -398,8 +409,7 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; 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 4882ccd976..7376d58e8f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -122,6 +122,7 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUser'); } + // parse inputs $resourcePath = "/user"; @@ -141,8 +142,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -202,6 +202,7 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithArrayInput'); } + // parse inputs $resourcePath = "/user/createWithArray"; @@ -221,8 +222,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -282,6 +282,7 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithListInput'); } + // parse inputs $resourcePath = "/user/createWithList"; @@ -301,8 +302,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -362,6 +362,7 @@ class UserApi if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); } + // parse inputs $resourcePath = "/user/{username}"; @@ -388,8 +389,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -445,6 +445,7 @@ class UserApi if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); } + // parse inputs $resourcePath = "/user/{username}"; @@ -471,8 +472,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -537,10 +537,12 @@ class UserApi if ($username === null) { 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'); } + // parse inputs $resourcePath = "/user/login"; @@ -566,8 +568,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -643,8 +644,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - + // for model (json/xml) if (isset($_tempBody)) { @@ -702,10 +702,12 @@ class UserApi if ($username === null) { 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'); } + // parse inputs $resourcePath = "/user/{username}"; @@ -732,8 +734,7 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - - // body params + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/FakeApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/FakeApiTest.php new file mode 100644 index 0000000000..47b8fa21b6 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/FakeApiTest.php @@ -0,0 +1,76 @@ + Date: Fri, 29 Apr 2016 11:04:27 +0800 Subject: [PATCH 2/2] change the validation to allParams --- .../src/main/resources/php/api.mustache | 33 +----- .../petstore/php/SwaggerClient-php/README.md | 2 +- .../php/SwaggerClient-php/lib/Api/FakeApi.php | 101 +++++++----------- .../php/SwaggerClient-php/lib/Api/PetApi.php | 32 +++--- .../SwaggerClient-php/lib/Api/StoreApi.php | 18 ++-- .../php/SwaggerClient-php/lib/Api/UserApi.php | 38 +++---- 6 files changed, 85 insertions(+), 139 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index c31eff8bc4..c0401940b4 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -123,6 +123,7 @@ use \{{invokerPackage}}\ObjectSerializer; if (${{paramName}} === null) { throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); } + {{/required}} {{#hasValidation}} {{#maxLength}} if (strlen(${{paramName}}) > {{maxLength}}) { @@ -151,7 +152,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{/pattern}} {{/hasValidation}} - {{/required}}{{/allParams}} + {{/allParams}} // parse inputs $resourcePath = "{{path}}"; @@ -201,33 +202,6 @@ use \{{invokerPackage}}\ObjectSerializer; {{#formParams}}// form params if (${{paramName}} !== null) { - {{#hasValidation}} - {{#maxLength}} - if (strlen(${{paramName}}) > {{maxLength}}) { - throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.'); - } - {{/maxLength}} - {{#minLength}} - if (strlen(${{paramName}}) > {{minLength}}) { - throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.'); - } - {{/minLength}} - {{#maximum}} - if (${{paramName}} > {{maximum}}) { - throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maximum}}.'); - } - {{/maximum}} - {{#minimum}} - if (${{paramName}} < {{minimum}}) { - throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minimum}}.'); - } - {{/minimum}} - {{#pattern}} - if (!preg_match("{{pattern}}", ${{paramName}})) { - throw new \InvalidArgumentException('invalid value for "{{paramName}}" when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); - } - {{/pattern}} - {{/hasValidation}} {{#isFile}} // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload @@ -240,8 +214,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{^isFile}} $formParams['{{baseName}}'] = $this->apiClient->getSerializer()->toFormValue(${{paramName}}); {{/isFile}} - } - {{/formParams}} + }{{/formParams}} {{#bodyParams}}// body params $_tempBody = null; if (isset(${{paramName}})) { diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index aa6ce69b76..e7d9b552b0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-28T02:26:28.980Z +- Build date: 2016-04-29T03:01:58.276Z - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements 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 f6f2e73950..ee15a10d02 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -151,7 +151,7 @@ class FakeApi throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); } - + // verify the required parameter 'double' is set if ($double === null) { throw new \InvalidArgumentException('Missing the required parameter $double when calling testEndpointParameters'); @@ -163,7 +163,7 @@ class FakeApi throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); } - + // verify the required parameter 'string' is set if ($string === null) { throw new \InvalidArgumentException('Missing the required parameter $string when calling testEndpointParameters'); @@ -172,12 +172,36 @@ class FakeApi throw new \InvalidArgumentException('invalid value for "string" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); } - + // verify the required parameter 'byte' is set if ($byte === null) { throw new \InvalidArgumentException('Missing the required parameter $byte when calling testEndpointParameters'); } - + if ($integer > 100.0) { + throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); + } + if ($integer < 10.0) { + throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); + } + + if ($int32 > 200.0) { + throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); + } + if ($int32 < 20.0) { + throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); + } + + if ($float > 987.6) { + throw new \InvalidArgumentException('invalid value for "$float" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); + } + + if (strlen($password) > 64) { + throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); + } + if (strlen($password) > 10) { + throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); + } + // parse inputs $resourcePath = "/fake"; @@ -199,86 +223,39 @@ class FakeApi // form params if ($integer !== null) { - if ($integer > 100.0) { - throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.0.'); - } - if ($integer < 10.0) { - throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.0.'); - } $formParams['integer'] = $this->apiClient->getSerializer()->toFormValue($integer); - } -// form params + }// form params if ($int32 !== null) { - if ($int32 > 200.0) { - throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.0.'); - } - if ($int32 < 20.0) { - throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.0.'); - } $formParams['int32'] = $this->apiClient->getSerializer()->toFormValue($int32); - } -// form params + }// form params if ($int64 !== null) { $formParams['int64'] = $this->apiClient->getSerializer()->toFormValue($int64); - } -// form params + }// form params if ($number !== null) { - if ($number > 543.2) { - throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); - } - if ($number < 32.1) { - throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); - } $formParams['number'] = $this->apiClient->getSerializer()->toFormValue($number); - } -// form params + }// form params if ($float !== null) { - if ($float > 987.6) { - throw new \InvalidArgumentException('invalid value for "$float" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); - } $formParams['float'] = $this->apiClient->getSerializer()->toFormValue($float); - } -// form params + }// form params if ($double !== null) { - if ($double > 123.4) { - throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); - } - if ($double < 67.8) { - throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); - } $formParams['double'] = $this->apiClient->getSerializer()->toFormValue($double); - } -// form params + }// form params if ($string !== null) { - if (!preg_match("/[a-z]/i", $string)) { - throw new \InvalidArgumentException('invalid value for "string" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i.'); - } $formParams['string'] = $this->apiClient->getSerializer()->toFormValue($string); - } -// form params + }// form params if ($byte !== null) { $formParams['byte'] = $this->apiClient->getSerializer()->toFormValue($byte); - } -// form params + }// form params if ($binary !== null) { $formParams['binary'] = $this->apiClient->getSerializer()->toFormValue($binary); - } -// form params + }// form params if ($date !== null) { $formParams['date'] = $this->apiClient->getSerializer()->toFormValue($date); - } -// form params + }// form params if ($date_time !== null) { $formParams['dateTime'] = $this->apiClient->getSerializer()->toFormValue($date_time); - } -// form params + }// form params if ($password !== null) { - if (strlen($password) > 64) { - throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); - } - if (strlen($password) > 10) { - throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); - } $formParams['password'] = $this->apiClient->getSerializer()->toFormValue($password); } 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 fff4e6be41..1154b72929 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -122,7 +122,6 @@ class PetApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling addPet'); } - // parse inputs $resourcePath = "/pet"; @@ -142,7 +141,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -209,7 +209,6 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); } - // parse inputs $resourcePath = "/pet/{petId}"; @@ -239,7 +238,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -300,7 +300,6 @@ class PetApi if ($status === null) { throw new \InvalidArgumentException('Missing the required parameter $status when calling findPetsByStatus'); } - // parse inputs $resourcePath = "/pet/findByStatus"; @@ -326,7 +325,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -394,7 +394,6 @@ class PetApi if ($tags === null) { throw new \InvalidArgumentException('Missing the required parameter $tags when calling findPetsByTags'); } - // parse inputs $resourcePath = "/pet/findByTags"; @@ -420,7 +419,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -488,7 +488,6 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); } - // parse inputs $resourcePath = "/pet/{petId}"; @@ -515,7 +514,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -585,7 +585,6 @@ class PetApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling updatePet'); } - // parse inputs $resourcePath = "/pet"; @@ -605,7 +604,8 @@ class PetApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -674,7 +674,6 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); } - // parse inputs $resourcePath = "/pet/{petId}"; @@ -704,8 +703,7 @@ class PetApi // form params if ($name !== null) { $formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name); - } -// form params + }// form params if ($status !== null) { $formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status); } @@ -774,7 +772,6 @@ class PetApi if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); } - // parse inputs $resourcePath = "/pet/{petId}/uploadImage"; @@ -804,8 +801,7 @@ class PetApi // form params if ($additional_metadata !== null) { $formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata); - } -// form params + }// form params if ($file !== null) { // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload 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 77d5b9ecba..27253a09f4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -126,7 +126,6 @@ class StoreApi throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.deleteOrder, must be bigger than or equal to 1.0.'); } - // parse inputs $resourcePath = "/store/order/{orderId}"; @@ -153,7 +152,8 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -202,8 +202,7 @@ class StoreApi */ public function getInventoryWithHttpInfo() { - - + // parse inputs $resourcePath = "/store/inventory"; $httpBody = ''; @@ -222,7 +221,8 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -299,7 +299,6 @@ class StoreApi throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be bigger than or equal to 1.0.'); } - // parse inputs $resourcePath = "/store/order/{orderId}"; @@ -326,7 +325,8 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -389,7 +389,6 @@ class StoreApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling placeOrder'); } - // parse inputs $resourcePath = "/store/order"; @@ -409,7 +408,8 @@ class StoreApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; 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 7376d58e8f..96c9fa6fc0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -122,7 +122,6 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUser'); } - // parse inputs $resourcePath = "/user"; @@ -142,7 +141,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -202,7 +202,6 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithArrayInput'); } - // parse inputs $resourcePath = "/user/createWithArray"; @@ -222,7 +221,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -282,7 +282,6 @@ class UserApi if ($body === null) { throw new \InvalidArgumentException('Missing the required parameter $body when calling createUsersWithListInput'); } - // parse inputs $resourcePath = "/user/createWithList"; @@ -302,7 +301,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body; @@ -362,7 +362,6 @@ class UserApi if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); } - // parse inputs $resourcePath = "/user/{username}"; @@ -389,7 +388,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -445,7 +445,6 @@ class UserApi if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); } - // parse inputs $resourcePath = "/user/{username}"; @@ -472,7 +471,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -537,12 +537,11 @@ class UserApi if ($username === null) { 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'); } - // parse inputs $resourcePath = "/user/login"; @@ -568,7 +567,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -624,8 +624,7 @@ class UserApi */ public function logoutUserWithHttpInfo() { - - + // parse inputs $resourcePath = "/user/logout"; $httpBody = ''; @@ -644,7 +643,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + + // for model (json/xml) if (isset($_tempBody)) { @@ -702,12 +702,11 @@ class UserApi if ($username === null) { 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'); } - // parse inputs $resourcePath = "/user/{username}"; @@ -734,7 +733,8 @@ class UserApi // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - // body params + + // body params $_tempBody = null; if (isset($body)) { $_tempBody = $body;