diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 84a1dca45ff..f62f341045b 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -338,6 +338,12 @@ class ApiClient(object): return self.rest_client.HEAD(url, query_params=query_params, headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache index 1481cbff3d5..07be648373a 100644 --- a/modules/swagger-codegen/src/main/resources/python/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache @@ -103,7 +103,7 @@ class RESTClientObject(object): and `multipart/form-data` """ method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH'] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS'] if post_params and body: raise ValueError( @@ -117,8 +117,8 @@ class RESTClientObject(object): headers['Content-Type'] = 'application/json' try: - # For `POST`, `PUT`, `PATCH` - if method in ['POST', 'PUT', 'PATCH']: + # For `POST`, `PUT`, `PATCH`, `OPTIONS` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']: if query_params: url += '?' + urlencode(query_params) if headers['Content-Type'] == 'application/json': @@ -172,6 +172,13 @@ class RESTClientObject(object): headers=headers, query_params=query_params) + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + body=body) + def DELETE(self, url, headers=None, query_params=None): return self.request("DELETE", url, headers=headers, @@ -226,22 +233,3 @@ class ApiException(Exception): error_message += "HTTP response body: {0}\n".format(self.body) return error_message - - - - - - - - - - - - - - - - - - - diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index f61c5d55262..6e7b59f36fd 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -9,8 +9,8 @@ from .models.order import Order # import apis into sdk package from .apis.user_api import UserApi -from .apis.pet_api import PetApi from .apis.store_api import StoreApi +from .apis.pet_api import PetApi # import ApiClient from .api_client import ApiClient diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index 1030bf9a838..b44c4a321a6 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -270,7 +270,7 @@ class ApiClient(object): if klass in [int, float, str, bool]: return self.__deserialize_primitive(data, klass) elif klass == object: - return self.__deserialize_object() + return self.__deserialize_object(data) elif klass == date: return self.__deserialize_date(data) elif klass == datetime: @@ -338,6 +338,12 @@ class ApiClient(object): return self.rest_client.HEAD(url, query_params=query_params, headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + body=body) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, @@ -495,13 +501,13 @@ class ApiClient(object): value = data return value - def __deserialize_object(self): + def __deserialize_object(self, value): """ - Deserializes empty object. + Return a original value. :return: object. """ - return object() + return value def __deserialize_date(self, string): """ diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index 592a56e282d..c0e09458f95 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -2,5 +2,5 @@ from __future__ import absolute_import # import apis into api package from .user_api import UserApi -from .pet_api import PetApi from .store_api import StoreApi +from .pet_api import PetApi 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 ad053a7d72d..b162cc534c3 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -409,7 +409,7 @@ class PetApi(object): select_header_content_type([]) # Authentication setting - auth_settings = ['api_key', 'petstore_auth'] + auth_settings = ['petstore_auth', 'api_key'] response = self.api_client.call_api(resource_path, method, path_params, diff --git a/samples/client/petstore/python/swagger_client/rest.py b/samples/client/petstore/python/swagger_client/rest.py index 1481cbff3d5..07be648373a 100644 --- a/samples/client/petstore/python/swagger_client/rest.py +++ b/samples/client/petstore/python/swagger_client/rest.py @@ -103,7 +103,7 @@ class RESTClientObject(object): and `multipart/form-data` """ method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH'] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS'] if post_params and body: raise ValueError( @@ -117,8 +117,8 @@ class RESTClientObject(object): headers['Content-Type'] = 'application/json' try: - # For `POST`, `PUT`, `PATCH` - if method in ['POST', 'PUT', 'PATCH']: + # For `POST`, `PUT`, `PATCH`, `OPTIONS` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']: if query_params: url += '?' + urlencode(query_params) if headers['Content-Type'] == 'application/json': @@ -172,6 +172,13 @@ class RESTClientObject(object): headers=headers, query_params=query_params) + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + body=body) + def DELETE(self, url, headers=None, query_params=None): return self.request("DELETE", url, headers=headers, @@ -226,22 +233,3 @@ class ApiException(Exception): error_message += "HTTP response body: {0}\n".format(self.body) return error_message - - - - - - - - - - - - - - - - - - -