Merge pull request #2266 from wing328/php_better_local_var

[Ruby][Python][PHP] better local variable naming for ruby, python and php
This commit is contained in:
wing328 2016-02-28 18:23:11 +08:00
commit f3a1f829d0
17 changed files with 418 additions and 201 deletions

View File

@ -52,7 +52,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
setReservedWordsLowerCase(
Arrays.asList(
// local variables used in api methods (endpoints)
"resourcePath", "method", "httpBody", "queryParams", "headerParams",
"resourcePath", "httpBody", "queryParams", "headerParams",
"formParams", "_header_accept", "_tempBody",
// PHP reserved words

View File

@ -59,8 +59,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
setReservedWordsLowerCase(
Arrays.asList(
// local variable name used in API methods (endpoints)
"all_params", "resource_path", "method", "path_params", "query_params",
"header_params", "form_params", "files", "body_params", "auth_settings",
"all_params", "resource_path", "path_params", "query_params",
"header_params", "form_params", "local_var_files", "body_params", "auth_settings",
// python reserved words
"and", "del", "from", "not", "while", "as", "elif", "global", "or", "with",
"assert", "else", "if", "pass", "yield", "break", "except", "import",

View File

@ -61,7 +61,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
setReservedWordsLowerCase(
Arrays.asList(
// local variable names used in API methods (endpoints)
"path", "query_params", "header_params", "_header_accept", "_header_accept_result",
"local_var_path", "query_params", "header_params", "_header_accept", "_header_accept_result",
"_header_content_type", "form_params", "post_body", "auth_names",
// ruby reserved keywords
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",

View File

@ -97,8 +97,6 @@ class {{classname}}(object):
{{/allParams}}
resource_path = '{{path}}'.replace('{format}', 'json')
method = '{{httpMethod}}'
path_params = {}
{{#pathParams}}
if '{{paramName}}' in params:
@ -118,10 +116,10 @@ class {{classname}}(object):
{{/headerParams}}
form_params = []
files = {}
local_var_files = {}
{{#formParams}}
if '{{paramName}}' in params:
{{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}
{{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}
{{/formParams}}
body_params = None
@ -143,13 +141,13 @@ class {{classname}}(object):
# Authentication setting
auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, '{{httpMethod}}',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}},
auth_settings=auth_settings,
callback=params.get('callback'))

View File

@ -47,7 +47,7 @@ module {{moduleName}}
end
{{/isEnum}}{{/required}}{{/allParams}}
# resource path
path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
local_var_path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
# query parameters
query_params = {}{{#queryParams}}{{#required}}
@ -77,7 +77,7 @@ module {{moduleName}}
{{/bodyParam}}{{#bodyParam}}post_body = @api_client.object_to_http_body({{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}})
{{/bodyParam}}
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, path,
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,

View File

@ -264,7 +264,7 @@ class PetApi
*
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (optional)
* @param string[] $status Status values that need to be considered for query (optional)
* @return \Swagger\Client\Model\Pet[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
@ -280,7 +280,7 @@ class PetApi
*
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (optional)
* @param string[] $status Status values that need to be considered for query (optional)
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/

View File

@ -91,6 +91,107 @@ class StoreApi
}
/**
* findOrdersByStatus
*
* Finds orders by status
*
* @param string $status Status value that needs to be considered for query (optional)
* @return \Swagger\Client\Model\Order[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findOrdersByStatus($status = null)
{
list($response, $statusCode, $httpHeader) = $this->findOrdersByStatusWithHttpInfo ($status);
return $response;
}
/**
* findOrdersByStatusWithHttpInfo
*
* Finds orders by status
*
* @param string $status Status value that needs to be considered for query (optional)
* @return Array of \Swagger\Client\Model\Order[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findOrdersByStatusWithHttpInfo($status = null)
{
// parse inputs
$resourcePath = "/store/findByStatus";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if ($status !== null) {
$queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// 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)
}
// this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_id');
if (strlen($apiKey) !== 0) {
$headerParams['x-test_api_client_id'] = $apiKey;
}
// this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret');
if (strlen($apiKey) !== 0) {
$headerParams['x-test_api_client_secret'] = $apiKey;
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, 'GET',
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order[]'
);
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order[]', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order[]', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* getInventory
*

View File

@ -65,6 +65,16 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase
}
/**
* Test case for findOrdersByStatus
*
* Finds orders by status
*
*/
public function test_findOrdersByStatus() {
}
/**
* Test case for getInventory
*

View File

@ -81,8 +81,6 @@ class PetApi(object):
resource_path = '/pet'.replace('{format}', 'json')
method = 'PUT'
path_params = {}
query_params = {}
@ -90,7 +88,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -109,13 +107,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'PUT',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -157,8 +155,6 @@ class PetApi(object):
resource_path = '/pet'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -166,7 +162,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -185,13 +181,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -200,7 +196,7 @@ class PetApi(object):
def find_pets_by_status(self, **kwargs):
"""
Finds Pets by status
Multiple status values can be provided with comma seperated strings
Multiple status values can be provided with comma separated strings
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
@ -212,7 +208,7 @@ class PetApi(object):
:param callback function: The callback function
for asynchronous request. (optional)
:param list[str] status: Status values that need to be considered for filter
:param list[str] status: Status values that need to be considered for query
:return: list[Pet]
If the method is called asynchronously,
returns the request thread.
@ -233,8 +229,6 @@ class PetApi(object):
resource_path = '/pet/findByStatus'.replace('{format}', 'json')
method = 'GET'
path_params = {}
query_params = {}
@ -244,7 +238,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -261,13 +255,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='list[Pet]',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -309,8 +303,6 @@ class PetApi(object):
resource_path = '/pet/findByTags'.replace('{format}', 'json')
method = 'GET'
path_params = {}
query_params = {}
@ -320,7 +312,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -337,13 +329,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='list[Pet]',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -388,8 +380,6 @@ class PetApi(object):
raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`")
resource_path = '/pet/{petId}'.replace('{format}', 'json')
method = 'GET'
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
@ -399,7 +389,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -416,13 +406,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['api_key', 'petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='Pet',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -469,8 +459,6 @@ class PetApi(object):
raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`")
resource_path = '/pet/{petId}'.replace('{format}', 'json')
method = 'POST'
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
@ -480,7 +468,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
if 'name' in params:
form_params.append(('name', params['name']))
if 'status' in params:
@ -501,13 +489,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -553,8 +541,6 @@ class PetApi(object):
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`")
resource_path = '/pet/{petId}'.replace('{format}', 'json')
method = 'DELETE'
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
@ -566,7 +552,7 @@ class PetApi(object):
header_params['api_key'] = params['api_key']
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -583,13 +569,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -636,8 +622,6 @@ class PetApi(object):
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`")
resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json')
method = 'POST'
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
@ -647,11 +631,11 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
if 'additional_metadata' in params:
form_params.append(('additionalMetadata', params['additional_metadata']))
if 'file' in params:
files['file'] = params['file']
local_var_files['file'] = params['file']
body_params = None
@ -668,13 +652,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -719,8 +703,6 @@ class PetApi(object):
raise ValueError("Missing the required parameter `pet_id` when calling `pet_pet_idtesting_byte_arraytrue_get`")
resource_path = '/pet/{petId}?testing_byte_array=true'.replace('{format}', 'json')
method = 'GET'
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
@ -730,7 +712,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -747,13 +729,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['api_key', 'petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='str',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -795,8 +777,6 @@ class PetApi(object):
resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -804,7 +784,7 @@ class PetApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -823,13 +803,13 @@ class PetApi(object):
# Authentication setting
auth_settings = ['petstore_auth']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))

View File

@ -45,6 +45,80 @@ class StoreApi(object):
config.api_client = ApiClient()
self.api_client = config.api_client
def find_orders_by_status(self, **kwargs):
"""
Finds orders by status
A single status value can be provided as a string
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.find_orders_by_status(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str status: Status value that needs to be considered for query
:return: list[Order]
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['status']
all_params.append('callback')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method find_orders_by_status" % key
)
params[key] = val
del params['kwargs']
resource_path = '/store/findByStatus'.replace('{format}', 'json')
path_params = {}
query_params = {}
if 'status' in params:
query_params['status'] = params['status']
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', 'application/xml'])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type([])
# Authentication setting
auth_settings = ['test_api_client_id', 'test_api_client_secret']
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='list[Order]',
auth_settings=auth_settings,
callback=params.get('callback'))
return response
def get_inventory(self, **kwargs):
"""
Returns pet inventories by status
@ -80,8 +154,6 @@ class StoreApi(object):
resource_path = '/store/inventory'.replace('{format}', 'json')
method = 'GET'
path_params = {}
query_params = {}
@ -89,7 +161,7 @@ class StoreApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -106,13 +178,13 @@ class StoreApi(object):
# Authentication setting
auth_settings = ['api_key']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='dict(str, int)',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -154,8 +226,6 @@ class StoreApi(object):
resource_path = '/store/order'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -163,7 +233,7 @@ class StoreApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -182,13 +252,13 @@ class StoreApi(object):
# Authentication setting
auth_settings = ['test_api_client_id', 'test_api_client_secret']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='Order',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -233,8 +303,6 @@ class StoreApi(object):
raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`")
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
method = 'GET'
path_params = {}
if 'order_id' in params:
path_params['orderId'] = params['order_id']
@ -244,7 +312,7 @@ class StoreApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -261,13 +329,13 @@ class StoreApi(object):
# Authentication setting
auth_settings = ['test_api_key_header', 'test_api_key_query']
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='Order',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -312,8 +380,6 @@ class StoreApi(object):
raise ValueError("Missing the required parameter `order_id` when calling `delete_order`")
resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
method = 'DELETE'
path_params = {}
if 'order_id' in params:
path_params['orderId'] = params['order_id']
@ -323,7 +389,7 @@ class StoreApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -340,13 +406,13 @@ class StoreApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))

View File

@ -81,8 +81,6 @@ class UserApi(object):
resource_path = '/user'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -90,7 +88,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -109,13 +107,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -157,8 +155,6 @@ class UserApi(object):
resource_path = '/user/createWithArray'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -166,7 +162,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -185,13 +181,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -233,8 +229,6 @@ class UserApi(object):
resource_path = '/user/createWithList'.replace('{format}', 'json')
method = 'POST'
path_params = {}
query_params = {}
@ -242,7 +236,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -261,13 +255,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -310,8 +304,6 @@ class UserApi(object):
resource_path = '/user/login'.replace('{format}', 'json')
method = 'GET'
path_params = {}
query_params = {}
@ -323,7 +315,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -340,13 +332,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='str',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -387,8 +379,6 @@ class UserApi(object):
resource_path = '/user/logout'.replace('{format}', 'json')
method = 'GET'
path_params = {}
query_params = {}
@ -396,7 +386,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -413,13 +403,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -464,8 +454,6 @@ class UserApi(object):
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`")
resource_path = '/user/{username}'.replace('{format}', 'json')
method = 'GET'
path_params = {}
if 'username' in params:
path_params['username'] = params['username']
@ -475,7 +463,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -492,13 +480,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type='User',
auth_settings=auth_settings,
callback=params.get('callback'))
@ -544,8 +532,6 @@ class UserApi(object):
raise ValueError("Missing the required parameter `username` when calling `update_user`")
resource_path = '/user/{username}'.replace('{format}', 'json')
method = 'PUT'
path_params = {}
if 'username' in params:
path_params['username'] = params['username']
@ -555,7 +541,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
if 'body' in params:
@ -574,13 +560,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'PUT',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))
@ -625,8 +611,6 @@ class UserApi(object):
raise ValueError("Missing the required parameter `username` when calling `delete_user`")
resource_path = '/user/{username}'.replace('{format}', 'json')
method = 'DELETE'
path_params = {}
if 'username' in params:
path_params['username'] = params['username']
@ -636,7 +620,7 @@ class UserApi(object):
header_params = {}
form_params = []
files = {}
local_var_files = {}
body_params = None
@ -653,13 +637,13 @@ class UserApi(object):
# Authentication setting
auth_settings = []
response = self.api_client.call_api(resource_path, method,
response = self.api_client.call_api(resource_path, 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=files,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
callback=params.get('callback'))

View File

@ -45,7 +45,7 @@ module Petstore
end
# resource path
path = "/pet".sub('{format}','json')
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
@ -68,7 +68,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -101,7 +101,7 @@ module Petstore
end
# resource path
path = "/pet".sub('{format}','json')
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
@ -124,7 +124,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -137,9 +137,9 @@ module Petstore
end
# Finds Pets by status
# Multiple status values can be provided with comma seperated strings
# Multiple status values can be provided with comma separated strings
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @option opts [Array<String>] :status Status values that need to be considered for query
# @return [Array<Pet>]
def find_pets_by_status(opts = {})
data, status_code, headers = find_pets_by_status_with_http_info(opts)
@ -147,9 +147,9 @@ module Petstore
end
# Finds Pets by status
# Multiple status values can be provided with comma seperated strings
# Multiple status values can be provided with comma separated strings
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @option opts [Array<String>] :status Status values that need to be considered for query
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_status_with_http_info(opts = {})
if @api_client.config.debugging
@ -157,7 +157,7 @@ module Petstore
end
# resource path
path = "/pet/findByStatus".sub('{format}','json')
local_var_path = "/pet/findByStatus".sub('{format}','json')
# query parameters
query_params = {}
@ -181,7 +181,7 @@ module Petstore
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -215,7 +215,7 @@ module Petstore
end
# resource path
path = "/pet/findByTags".sub('{format}','json')
local_var_path = "/pet/findByTags".sub('{format}','json')
# query parameters
query_params = {}
@ -239,7 +239,7 @@ module Petstore
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -276,7 +276,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling get_pet_by_id" if pet_id.nil?
# resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -298,8 +298,8 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth', 'api_key']
data, status_code, headers = @api_client.call_api(:GET, path,
auth_names = ['api_key', 'petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -340,7 +340,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
# resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -365,7 +365,7 @@ module Petstore
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -403,7 +403,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
# resource path
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -427,7 +427,7 @@ module Petstore
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -467,7 +467,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
# resource path
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -492,7 +492,7 @@ module Petstore
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -528,7 +528,7 @@ module Petstore
fail "Missing the required parameter 'pet_id' when calling pet_pet_idtesting_byte_arraytrue_get" if pet_id.nil?
# resource path
path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
@ -550,8 +550,8 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['petstore_auth', 'api_key']
data, status_code, headers = @api_client.call_api(:GET, path,
auth_names = ['api_key', 'petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -585,7 +585,7 @@ module Petstore
end
# resource path
path = "/pet?testing_byte_array=true".sub('{format}','json')
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
# query parameters
query_params = {}
@ -608,7 +608,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,

View File

@ -24,6 +24,68 @@ module Petstore
@api_client = api_client
end
# Finds orders by status
# A single status value can be provided as a string
# @param [Hash] opts the optional parameters
# @option opts [String] :status Status value that needs to be considered for query
# @return [Array<Order>]
def find_orders_by_status(opts = {})
data, status_code, headers = find_orders_by_status_with_http_info(opts)
return data
end
# Finds orders by status
# A single status value can be provided as a string
# @param [Hash] opts the optional parameters
# @option opts [String] :status Status value that needs to be considered for query
# @return [Array<(Array<Order>, Fixnum, Hash)>] Array<Order> data, response status code and response headers
def find_orders_by_status_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#find_orders_by_status ..."
end
if opts[:'status'] && !['placed', 'approved', 'delivered'].include?(opts[:'status'])
fail 'invalid value for "status", must be one of placed, approved, delivered'
end
# resource path
local_var_path = "/store/findByStatus".sub('{format}','json')
# query parameters
query_params = {}
query_params[:'status'] = opts[:'status'] if opts[:'status']
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Array<Order>')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#find_orders_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Returns pet inventories by status
# Returns a map of status codes to quantities
# @param [Hash] opts the optional parameters
@ -43,7 +105,7 @@ module Petstore
end
# resource path
path = "/store/inventory".sub('{format}','json')
local_var_path = "/store/inventory".sub('{format}','json')
# query parameters
query_params = {}
@ -66,7 +128,7 @@ module Petstore
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -100,7 +162,7 @@ module Petstore
end
# resource path
path = "/store/order".sub('{format}','json')
local_var_path = "/store/order".sub('{format}','json')
# query parameters
query_params = {}
@ -123,7 +185,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -160,7 +222,7 @@ module Petstore
fail "Missing the required parameter 'order_id' when calling get_order_by_id" if order_id.nil?
# resource path
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
# query parameters
query_params = {}
@ -182,8 +244,8 @@ module Petstore
# http body (model)
post_body = nil
auth_names = ['test_api_key_query', 'test_api_key_header']
data, status_code, headers = @api_client.call_api(:GET, path,
auth_names = ['test_api_key_header', 'test_api_key_query']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -220,7 +282,7 @@ module Petstore
fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
# resource path
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
# query parameters
query_params = {}
@ -243,7 +305,7 @@ module Petstore
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,

View File

@ -45,7 +45,7 @@ module Petstore
end
# resource path
path = "/user".sub('{format}','json')
local_var_path = "/user".sub('{format}','json')
# query parameters
query_params = {}
@ -68,7 +68,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -101,7 +101,7 @@ module Petstore
end
# resource path
path = "/user/createWithArray".sub('{format}','json')
local_var_path = "/user/createWithArray".sub('{format}','json')
# query parameters
query_params = {}
@ -124,7 +124,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -157,7 +157,7 @@ module Petstore
end
# resource path
path = "/user/createWithList".sub('{format}','json')
local_var_path = "/user/createWithList".sub('{format}','json')
# query parameters
query_params = {}
@ -180,7 +180,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -215,7 +215,7 @@ module Petstore
end
# resource path
path = "/user/login".sub('{format}','json')
local_var_path = "/user/login".sub('{format}','json')
# query parameters
query_params = {}
@ -240,7 +240,7 @@ module Petstore
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -272,7 +272,7 @@ module Petstore
end
# resource path
path = "/user/logout".sub('{format}','json')
local_var_path = "/user/logout".sub('{format}','json')
# query parameters
query_params = {}
@ -295,7 +295,7 @@ module Petstore
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -331,7 +331,7 @@ module Petstore
fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
# resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
@ -354,7 +354,7 @@ module Petstore
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -393,7 +393,7 @@ module Petstore
fail "Missing the required parameter 'username' when calling update_user" if username.nil?
# resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
@ -416,7 +416,7 @@ module Petstore
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -452,7 +452,7 @@ module Petstore
fail "Missing the required parameter 'username' when calling delete_user" if username.nil?
# resource path
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
@ -475,7 +475,7 @@ module Petstore
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,

View File

@ -157,26 +157,12 @@ module Petstore
# Returns Auth Settings hash for api client.
def auth_settings
{
'petstore_auth' =>
{
type: 'oauth2',
in: 'header',
key: 'Authorization',
value: "Bearer #{access_token}"
},
'test_api_client_id' =>
'test_api_key_header' =>
{
type: 'api_key',
in: 'header',
key: 'x-test_api_client_id',
value: api_key_with_prefix('x-test_api_client_id')
},
'test_api_client_secret' =>
{
type: 'api_key',
in: 'header',
key: 'x-test_api_client_secret',
value: api_key_with_prefix('x-test_api_client_secret')
key: 'test_api_key_header',
value: api_key_with_prefix('test_api_key_header')
},
'api_key' =>
{
@ -185,6 +171,20 @@ module Petstore
key: 'api_key',
value: api_key_with_prefix('api_key')
},
'test_api_client_secret' =>
{
type: 'api_key',
in: 'header',
key: 'x-test_api_client_secret',
value: api_key_with_prefix('x-test_api_client_secret')
},
'test_api_client_id' =>
{
type: 'api_key',
in: 'header',
key: 'x-test_api_client_id',
value: api_key_with_prefix('x-test_api_client_id')
},
'test_api_key_query' =>
{
type: 'api_key',
@ -192,12 +192,12 @@ module Petstore
key: 'test_api_key_query',
value: api_key_with_prefix('test_api_key_query')
},
'test_api_key_header' =>
'petstore_auth' =>
{
type: 'api_key',
type: 'oauth2',
in: 'header',
key: 'test_api_key_header',
value: api_key_with_prefix('test_api_key_header')
key: 'Authorization',
value: "Bearer #{access_token}"
},
}
end

View File

@ -70,9 +70,9 @@ describe 'PetApi' do
# unit tests for find_pets_by_status
# Finds Pets by status
# Multiple status values can be provided with comma seperated strings
# Multiple status values can be provided with comma separated strings
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @option opts [Array<String>] :status Status values that need to be considered for query
# @return [Array<Pet>]
describe 'find_pets_by_status test' do
it "should work" do

View File

@ -36,6 +36,22 @@ describe 'StoreApi' do
end
end
# unit tests for find_orders_by_status
# Finds orders by status
# A single status value can be provided as a string
# @param [Hash] opts the optional parameters
# @option opts [String] :status Status value that needs to be considered for query
# @return [Array<Order>]
describe 'find_orders_by_status test' do
it "should work" do
# assertion here
# should be_a()
# should be_nil
# should ==
# should_not ==
end
end
# unit tests for get_inventory
# Returns pet inventories by status
# Returns a map of status codes to quantities