diff --git a/modules/swagger-codegen/src/main/resources/python/swagger.mustache b/modules/swagger-codegen/src/main/resources/python/swagger.mustache index 0483041116d..d7b896d3c0e 100644 --- a/modules/swagger-codegen/src/main/resources/python/swagger.mustache +++ b/modules/swagger-codegen/src/main/resources/python/swagger.mustache @@ -62,11 +62,12 @@ class ApiClient(object): body=None, post_params=None, files=None, response=None, auth_settings=None): # headers parameters - headers_params = self.default_headers.copy().update(header_params) + header_params = header_params or {} + header_params.update(self.default_headers) if self.cookie: - headers_params['Cookie'] = self.cookie - if headers_params: - headers_params = ApiClient.sanitize_for_serialization(headers_params) + header_params['Cookie'] = self.cookie + if header_params: + header_params = ApiClient.sanitize_for_serialization(header_params) # path parameters if path_params: @@ -86,7 +87,7 @@ class ApiClient(object): post_params = self.sanitize_for_serialization(post_params) # auth setting - self.update_params_for_auth(headers_params, query_params, auth_settings) + self.update_params_for_auth(header_params, query_params, auth_settings) # body if body: @@ -96,7 +97,7 @@ class ApiClient(object): url = self.host + resource_path # perform request and return response - response_data = self.request(method, url, query_params=query_params, headers=headers_params, + response_data = self.request(method, url, query_params=query_params, headers=header_params, post_params=post_params, body=body) # deserialize response data @@ -301,3 +302,4 @@ class ApiClient(object): raise ValueError('Authentication token must be in `query` or `header`') + diff --git a/samples/client/petstore/python/SwaggerPetstore-python/.coverage b/samples/client/petstore/python/SwaggerPetstore-python/.coverage deleted file mode 100644 index 50a2ec114f9..00000000000 Binary files a/samples/client/petstore/python/SwaggerPetstore-python/.coverage and /dev/null differ diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/PKG-INFO b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/PKG-INFO deleted file mode 100644 index ade0b731202..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/PKG-INFO +++ /dev/null @@ -1,12 +0,0 @@ -Metadata-Version: 1.0 -Name: SwaggerPetstore -Version: 1.0.0 -Summary: Swagger Petstore -Home-page: UNKNOWN -Author: UNKNOWN -Author-email: apiteam@wordnik.com -License: UNKNOWN -Description: This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -Keywords: Swagger,Swagger Petstore -Platform: UNKNOWN diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/SOURCES.txt b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/SOURCES.txt deleted file mode 100644 index 94955251c31..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/SOURCES.txt +++ /dev/null @@ -1,25 +0,0 @@ -setup.cfg -setup.py -SwaggerPetstore/__init__.py -SwaggerPetstore/config.py -SwaggerPetstore/rest.py -SwaggerPetstore/swagger.py -SwaggerPetstore/util.py -SwaggerPetstore.egg-info/PKG-INFO -SwaggerPetstore.egg-info/SOURCES.txt -SwaggerPetstore.egg-info/dependency_links.txt -SwaggerPetstore.egg-info/requires.txt -SwaggerPetstore.egg-info/top_level.txt -SwaggerPetstore/apis/__init__.py -SwaggerPetstore/apis/pet_api.py -SwaggerPetstore/apis/store_api.py -SwaggerPetstore/apis/user_api.py -SwaggerPetstore/models/__init__.py -SwaggerPetstore/models/category.py -SwaggerPetstore/models/order.py -SwaggerPetstore/models/pet.py -SwaggerPetstore/models/tag.py -SwaggerPetstore/models/user.py -tests/__init__.py -tests/test_api_client.py -tests/test_pet_api.py \ No newline at end of file diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/dependency_links.txt b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/dependency_links.txt deleted file mode 100644 index 8b137891791..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/requires.txt b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/requires.txt deleted file mode 100644 index cf46870af1e..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/requires.txt +++ /dev/null @@ -1,2 +0,0 @@ -urllib3 >= 1.10 -six >= 1.9 \ No newline at end of file diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/top_level.txt b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/top_level.txt deleted file mode 100644 index 58cccc9f2e4..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore.egg-info/top_level.txt +++ /dev/null @@ -1,2 +0,0 @@ -tests -SwaggerPetstore diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/config.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/config.py index ec3dbe8efb4..46e60ccf417 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/config.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/config.py @@ -15,8 +15,7 @@ def get_basic_auth_token(): global username global password - if username and password: - return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization') + return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization') def auth_settings(): return { diff --git a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py index f01192dd46b..d7b896d3c0e 100644 --- a/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py +++ b/samples/client/petstore/python/SwaggerPetstore-python/SwaggerPetstore/swagger.py @@ -62,12 +62,12 @@ class ApiClient(object): body=None, post_params=None, files=None, response=None, auth_settings=None): # headers parameters - headers = self.default_headers.copy() - headers.update(header_params) + header_params = header_params or {} + header_params.update(self.default_headers) if self.cookie: - headers['Cookie'] = self.cookie - if headers: - headers = self.sanitize_for_serialization(headers) + header_params['Cookie'] = self.cookie + if header_params: + header_params = ApiClient.sanitize_for_serialization(header_params) # path parameters if path_params: @@ -87,7 +87,7 @@ class ApiClient(object): post_params = self.sanitize_for_serialization(post_params) # auth setting - self.update_params_for_auth(headers, query_params, auth_settings) + self.update_params_for_auth(header_params, query_params, auth_settings) # body if body: @@ -97,7 +97,7 @@ class ApiClient(object): url = self.host + resource_path # perform request and return response - response_data = self.request(method, url, query_params=query_params, headers=headers, + response_data = self.request(method, url, query_params=query_params, headers=header_params, post_params=post_params, body=body) # deserialize response data @@ -302,3 +302,4 @@ class ApiClient(object): raise ValueError('Authentication token must be in `query` or `header`') + diff --git a/samples/client/petstore/python/SwaggerPetstore-python/dev-requirements.txt.log b/samples/client/petstore/python/SwaggerPetstore-python/dev-requirements.txt.log deleted file mode 100644 index 0549f97e65f..00000000000 --- a/samples/client/petstore/python/SwaggerPetstore-python/dev-requirements.txt.log +++ /dev/null @@ -1,5 +0,0 @@ -Requirement already satisfied (use --upgrade to upgrade): nose in /Users/geekerzp/.virtualenvs/python2/lib/python2.7/site-packages (from -r dev-requirements.txt (line 1)) -Requirement already satisfied (use --upgrade to upgrade): tox in /Users/geekerzp/.virtualenvs/python2/lib/python2.7/site-packages (from -r dev-requirements.txt (line 2)) -Requirement already satisfied (use --upgrade to upgrade): coverage in /Users/geekerzp/.virtualenvs/python2/lib/python2.7/site-packages (from -r dev-requirements.txt (line 3)) -Requirement already satisfied (use --upgrade to upgrade): randomize in /Users/geekerzp/.virtualenvs/python2/lib/python2.7/site-packages (from -r dev-requirements.txt (line 4)) -Cleaning up...