From f68e93c662eec542f6f8dd25472800be93260bad Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 28 Feb 2016 11:48:14 +0800 Subject: [PATCH 1/2] better local variable naming for ruby, python and php --- .../codegen/languages/PhpClientCodegen.java | 2 +- .../languages/PythonClientCodegen.java | 2 +- .../codegen/languages/RubyClientCodegen.java | 2 +- .../src/main/resources/python/api.mustache | 6 +- .../src/main/resources/ruby/api.mustache | 4 +- .../php/SwaggerClient-php/lib/Api/PetApi.php | 4 +- .../SwaggerClient-php/lib/Api/StoreApi.php | 101 ++++++++++++++++++ .../lib/Tests/StoreApiTest.php | 10 ++ .../python/swagger_client/apis/pet_api.py | 46 ++++---- .../python/swagger_client/apis/store_api.py | 92 ++++++++++++++-- .../python/swagger_client/apis/user_api.py | 32 +++--- .../petstore/ruby/lib/petstore/api/pet_api.rb | 52 ++++----- .../ruby/lib/petstore/api/store_api.rb | 80 ++++++++++++-- .../ruby/lib/petstore/api/user_api.rb | 32 +++--- .../ruby/lib/petstore/configuration.rb | 42 ++++---- .../petstore/ruby/spec/api/PetApi_spec.rb | 4 +- .../petstore/ruby/spec/api/StoreApi_spec.rb | 16 +++ 17 files changed, 396 insertions(+), 131 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index fcb187cc80d..09cc9665b02 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -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 diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 5115a5d1f1b..4a5af07cf8b 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -60,7 +60,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig 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", + "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", diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 71f7437ece4..e7305f56b38 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -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__", diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 9b0559fb6d1..9296cb0b0c2 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -118,10 +118,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 @@ -149,7 +149,7 @@ class {{classname}}(object): 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')) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index a48dfd565c0..522807541d9 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -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, 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 b77d3b237f1..c83eec73104 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -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 */ 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 8163ef43b39..7945d21be76 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -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 * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php index 899f5791c8a..8ccedf892a0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php @@ -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 * diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index dacafe6e1ca..4a6c7b40a06 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -90,7 +90,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -115,7 +115,7 @@ class PetApi(object): 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')) @@ -166,7 +166,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -191,7 +191,7 @@ class PetApi(object): 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 +200,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 +212,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. @@ -244,7 +244,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -267,7 +267,7 @@ class PetApi(object): 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')) @@ -320,7 +320,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -343,7 +343,7 @@ class PetApi(object): 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')) @@ -399,7 +399,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -422,7 +422,7 @@ class PetApi(object): 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')) @@ -480,7 +480,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: @@ -507,7 +507,7 @@ class PetApi(object): 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')) @@ -566,7 +566,7 @@ class PetApi(object): header_params['api_key'] = params['api_key'] form_params = [] - files = {} + local_var_files = {} body_params = None @@ -589,7 +589,7 @@ class PetApi(object): 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')) @@ -647,11 +647,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 @@ -674,7 +674,7 @@ class PetApi(object): 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')) @@ -730,7 +730,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -753,7 +753,7 @@ class PetApi(object): 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')) @@ -804,7 +804,7 @@ class PetApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -829,7 +829,7 @@ class PetApi(object): 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')) diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index dabaac93458..b0a60dc4807 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -45,6 +45,82 @@ 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') + method = 'GET' + + 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, method, + 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 @@ -89,7 +165,7 @@ class StoreApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -112,7 +188,7 @@ class StoreApi(object): 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')) @@ -163,7 +239,7 @@ class StoreApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -188,7 +264,7 @@ class StoreApi(object): 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')) @@ -244,7 +320,7 @@ class StoreApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -267,7 +343,7 @@ class StoreApi(object): 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')) @@ -323,7 +399,7 @@ class StoreApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -346,7 +422,7 @@ class StoreApi(object): 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')) diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index 4e87823398e..586bc413ba0 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -90,7 +90,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -115,7 +115,7 @@ class UserApi(object): 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')) @@ -166,7 +166,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -191,7 +191,7 @@ class UserApi(object): 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')) @@ -242,7 +242,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -267,7 +267,7 @@ class UserApi(object): 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')) @@ -323,7 +323,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -346,7 +346,7 @@ class UserApi(object): 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')) @@ -396,7 +396,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -419,7 +419,7 @@ class UserApi(object): 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')) @@ -475,7 +475,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -498,7 +498,7 @@ class UserApi(object): 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')) @@ -555,7 +555,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None if 'body' in params: @@ -580,7 +580,7 @@ class UserApi(object): 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,7 +636,7 @@ class UserApi(object): header_params = {} form_params = [] - files = {} + local_var_files = {} body_params = None @@ -659,7 +659,7 @@ class UserApi(object): 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')) diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index 1a3a32f735f..1bf483b1252 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -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] :status Status values that need to be considered for filter + # @option opts [Array] :status Status values that need to be considered for query # @return [Array] 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] :status Status values that need to be considered for filter + # @option opts [Array] :status Status values that need to be considered for query # @return [Array<(Array, Fixnum, Hash)>] Array 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, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 828435653b2..5fbd94c9601 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -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] + 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, Fixnum, Hash)>] Array 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') + 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, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index edd110768e6..9b883755347 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -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, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 60f689cda6d..e5f39898027 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -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 diff --git a/samples/client/petstore/ruby/spec/api/PetApi_spec.rb b/samples/client/petstore/ruby/spec/api/PetApi_spec.rb index 95e33b85567..0d4b6ac3519 100644 --- a/samples/client/petstore/ruby/spec/api/PetApi_spec.rb +++ b/samples/client/petstore/ruby/spec/api/PetApi_spec.rb @@ -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] :status Status values that need to be considered for filter + # @option opts [Array] :status Status values that need to be considered for query # @return [Array] describe 'find_pets_by_status test' do it "should work" do diff --git a/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb b/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb index 81ba5f07f0d..a64b24ebca6 100644 --- a/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb +++ b/samples/client/petstore/ruby/spec/api/StoreApi_spec.rb @@ -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] + 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 From 742e3f5070cad1276f246d220409d145912f4bef Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 28 Feb 2016 16:51:50 +0800 Subject: [PATCH 2/2] remove 'method' from python api --- .../languages/PythonClientCodegen.java | 2 +- .../src/main/resources/python/api.mustache | 4 +- .../python/swagger_client/apis/pet_api.py | 40 +++++-------------- .../python/swagger_client/apis/store_api.py | 20 +++------- .../python/swagger_client/apis/user_api.py | 32 ++++----------- 5 files changed, 25 insertions(+), 73 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 4a5af07cf8b..8f375519d68 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -59,7 +59,7 @@ 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", + "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", diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 9296cb0b0c2..4d8b712a425 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -97,8 +97,6 @@ class {{classname}}(object): {{/allParams}} resource_path = '{{path}}'.replace('{format}', 'json') - method = '{{httpMethod}}' - path_params = {} {{#pathParams}} if '{{paramName}}' in params: @@ -143,7 +141,7 @@ 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, diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 4a6c7b40a06..5f14852ba77 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -81,8 +81,6 @@ class PetApi(object): resource_path = '/pet'.replace('{format}', 'json') - method = 'PUT' - path_params = {} query_params = {} @@ -109,7 +107,7 @@ 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, @@ -157,8 +155,6 @@ class PetApi(object): resource_path = '/pet'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -185,7 +181,7 @@ 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, @@ -233,8 +229,6 @@ class PetApi(object): resource_path = '/pet/findByStatus'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -261,7 +255,7 @@ 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, @@ -309,8 +303,6 @@ class PetApi(object): resource_path = '/pet/findByTags'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -337,7 +329,7 @@ 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, @@ -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'] @@ -416,7 +406,7 @@ 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, @@ -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'] @@ -501,7 +489,7 @@ 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, @@ -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'] @@ -583,7 +569,7 @@ 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, @@ -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'] @@ -668,7 +652,7 @@ 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, @@ -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'] @@ -747,7 +729,7 @@ 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, @@ -795,8 +777,6 @@ class PetApi(object): resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -823,7 +803,7 @@ 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, diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index b0a60dc4807..ce524916aa4 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -81,8 +81,6 @@ class StoreApi(object): resource_path = '/store/findByStatus'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -109,7 +107,7 @@ 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, 'GET', path_params, query_params, header_params, @@ -156,8 +154,6 @@ class StoreApi(object): resource_path = '/store/inventory'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -182,7 +178,7 @@ 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, @@ -230,8 +226,6 @@ class StoreApi(object): resource_path = '/store/order'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -258,7 +252,7 @@ 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, @@ -309,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'] @@ -337,7 +329,7 @@ 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, @@ -388,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'] @@ -416,7 +406,7 @@ 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, diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index 586bc413ba0..a83243cc245 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -81,8 +81,6 @@ class UserApi(object): resource_path = '/user'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -109,7 +107,7 @@ 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, @@ -157,8 +155,6 @@ class UserApi(object): resource_path = '/user/createWithArray'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -185,7 +181,7 @@ 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, @@ -233,8 +229,6 @@ class UserApi(object): resource_path = '/user/createWithList'.replace('{format}', 'json') - method = 'POST' - path_params = {} query_params = {} @@ -261,7 +255,7 @@ 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, @@ -310,8 +304,6 @@ class UserApi(object): resource_path = '/user/login'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -340,7 +332,7 @@ 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, @@ -387,8 +379,6 @@ class UserApi(object): resource_path = '/user/logout'.replace('{format}', 'json') - method = 'GET' - path_params = {} query_params = {} @@ -413,7 +403,7 @@ 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, @@ -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'] @@ -492,7 +480,7 @@ 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, @@ -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'] @@ -574,7 +560,7 @@ 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, @@ -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'] @@ -653,7 +637,7 @@ 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,