From ef53f08b09e87e0ee7bc021bd5446b5aeb0d902a Mon Sep 17 00:00:00 2001 From: rompic Date: Wed, 24 May 2017 17:26:33 +0200 Subject: [PATCH] fixed #5692 and regenerated samples (#5698) --- .../main/resources/python/api_doc.mustache | 2 +- .../python/docs/FakeApi.md | 2 +- .../python/petstore_api/api_client.py | 15 +++--- .../petstore_api/models/model_return.py | 32 +++++++------ samples/client/petstore/python/README.md | 4 +- .../client/petstore/python/docs/FakeApi.md | 14 +++--- samples/client/petstore/python/docs/PetApi.md | 16 +++---- .../client/petstore/python/docs/StoreApi.md | 8 ++-- .../client/petstore/python/docs/UserApi.md | 16 +++---- .../petstore/python/petstore_api/__init__.py | 4 +- .../python/petstore_api/apis/fake_api.py | 8 ++-- .../python/petstore_api/models/__init__.py | 4 +- .../petstore_api/models/outer_boolean.py | 28 ++++++----- .../petstore_api/models/outer_composite.py | 48 ++++++++++++------- .../petstore_api/models/outer_number.py | 28 ++++++----- .../petstore_api/models/outer_string.py | 28 ++++++----- 16 files changed, 145 insertions(+), 112 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache index 689e9ff2bb7..278b160e524 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache @@ -19,7 +19,7 @@ Method | HTTP request | Description ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException diff --git a/samples/client/petstore-security-test/python/docs/FakeApi.md b/samples/client/petstore-security-test/python/docs/FakeApi.md index c3f15c2b4b7..e35d744ef36 100644 --- a/samples/client/petstore-security-test/python/docs/FakeApi.md +++ b/samples/client/petstore-security-test/python/docs/FakeApi.md @@ -14,7 +14,7 @@ To test code injection */ ' \" =end -- \\r\\n \\n \\r ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore-security-test/python/petstore_api/api_client.py b/samples/client/petstore-security-test/python/petstore_api/api_client.py index 73bbc40eaa3..e5d34393dfc 100644 --- a/samples/client/petstore-security-test/python/petstore_api/api_client.py +++ b/samples/client/petstore-security-test/python/petstore_api/api_client.py @@ -617,16 +617,17 @@ class ApiClient(object): :param klass: class literal. :return: model object. """ - instance = klass() - - if not instance.swagger_types: + if not klass.swagger_types: return data - for attr, attr_type in iteritems(instance.swagger_types): + kwargs = {} + for attr, attr_type in iteritems(klass.swagger_types): if data is not None \ - and instance.attribute_map[attr] in data \ + and klass.attribute_map[attr] in data \ and isinstance(data, (list, dict)): - value = data[instance.attribute_map[attr]] - setattr(instance, attr, self.__deserialize(value, attr_type)) + value = data[klass.attribute_map[attr]] + kwargs[attr] = self.__deserialize(value, attr_type) + + instance = klass(**kwargs) return instance diff --git a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py index 80673374e7a..6a57ba570a4 100644 --- a/samples/client/petstore-security-test/python/petstore_api/models/model_return.py +++ b/samples/client/petstore-security-test/python/petstore_api/models/model_return.py @@ -21,28 +21,30 @@ class ModelReturn(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + '_return': 'int' + } + + attribute_map = { + '_return': 'return' + } + def __init__(self, _return=None): """ ModelReturn - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. """ - self.swagger_types = { - '_return': 'int' - } - - self.attribute_map = { - '_return': 'return' - } self.__return = None - # TODO: let required properties as mandatory parameter in the constructor. - # - to check if required property is not None (e.g. by calling setter) - # - ApiClient.__deserialize_model has to be adapted as well if _return is not None: self._return = _return diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index d7f84c355f0..f10eb1d595e 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -107,11 +107,9 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [Capitalization](docs/Capitalization.md) - - [Cat](docs/Cat.md) - [Category](docs/Category.md) - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - - [Dog](docs/Dog.md) - [EnumArrays](docs/EnumArrays.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) @@ -135,6 +133,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [Tag](docs/Tag.md) - [User](docs/User.md) + - [Cat](docs/Cat.md) + - [Dog](docs/Dog.md) ## Documentation For Authorization diff --git a/samples/client/petstore/python/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index c17b8e743f3..d27831bc178 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -22,7 +22,7 @@ Test serialization of outer boolean types ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -69,7 +69,7 @@ Test serialization of object with outer number type ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -116,7 +116,7 @@ Test serialization of outer number types ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -163,7 +163,7 @@ Test serialization of outer string types ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -210,7 +210,7 @@ To test \"client\" model ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -258,7 +258,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -335,7 +335,7 @@ To test enum parameters ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md index a88c30a5cac..00b49b181f9 100644 --- a/samples/client/petstore/python/docs/PetApi.md +++ b/samples/client/petstore/python/docs/PetApi.md @@ -23,7 +23,7 @@ Add a new pet to the store ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -73,7 +73,7 @@ Deletes a pet ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -125,7 +125,7 @@ Multiple status values can be provided with comma separated strings ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -176,7 +176,7 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -227,7 +227,7 @@ Returns a single pet ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -280,7 +280,7 @@ Update an existing pet ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -330,7 +330,7 @@ Updates a pet in the store with form data ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -384,7 +384,7 @@ uploads an image ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md index 25c66e25ab2..e06d3989d99 100644 --- a/samples/client/petstore/python/docs/StoreApi.md +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -19,7 +19,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -66,7 +66,7 @@ Returns a map of status codes to quantities ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -115,7 +115,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -163,7 +163,7 @@ Place an order for a pet ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore/python/docs/UserApi.md b/samples/client/petstore/python/docs/UserApi.md index 96620313189..5b73179dce3 100644 --- a/samples/client/petstore/python/docs/UserApi.md +++ b/samples/client/petstore/python/docs/UserApi.md @@ -23,7 +23,7 @@ This can only be done by the logged in user. ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -70,7 +70,7 @@ Creates list of users with given input array ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -117,7 +117,7 @@ Creates list of users with given input array ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -164,7 +164,7 @@ This can only be done by the logged in user. ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -211,7 +211,7 @@ Get user by user name ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -259,7 +259,7 @@ Logs user into the system ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -309,7 +309,7 @@ Logs out current logged in user session ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException @@ -352,7 +352,7 @@ This can only be done by the logged in user. ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore/python/petstore_api/__init__.py b/samples/client/petstore/python/petstore_api/__init__.py index f9c576b13e7..23b4881f563 100644 --- a/samples/client/petstore/python/petstore_api/__init__.py +++ b/samples/client/petstore/python/petstore_api/__init__.py @@ -22,11 +22,9 @@ from .models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from .models.array_of_number_only import ArrayOfNumberOnly from .models.array_test import ArrayTest from .models.capitalization import Capitalization -from .models.cat import Cat from .models.category import Category from .models.class_model import ClassModel from .models.client import Client -from .models.dog import Dog from .models.enum_arrays import EnumArrays from .models.enum_class import EnumClass from .models.enum_test import EnumTest @@ -50,6 +48,8 @@ from .models.read_only_first import ReadOnlyFirst from .models.special_model_name import SpecialModelName from .models.tag import Tag from .models.user import User +from .models.cat import Cat +from .models.dog import Dog # import apis into sdk package from .apis.fake_api import FakeApi diff --git a/samples/client/petstore/python/petstore_api/apis/fake_api.py b/samples/client/petstore/python/petstore_api/apis/fake_api.py index 9ee76132b87..73265f2ca92 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_api.py @@ -105,7 +105,7 @@ class FakeApi(object): path_params = {} - query_params = {} + query_params = [] header_params = {} @@ -198,7 +198,7 @@ class FakeApi(object): path_params = {} - query_params = {} + query_params = [] header_params = {} @@ -291,7 +291,7 @@ class FakeApi(object): path_params = {} - query_params = {} + query_params = [] header_params = {} @@ -384,7 +384,7 @@ class FakeApi(object): path_params = {} - query_params = {} + query_params = [] header_params = {} diff --git a/samples/client/petstore/python/petstore_api/models/__init__.py b/samples/client/petstore/python/petstore_api/models/__init__.py index ea4684d5482..21b5d20fa3c 100644 --- a/samples/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/client/petstore/python/petstore_api/models/__init__.py @@ -22,11 +22,9 @@ from .array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from .array_of_number_only import ArrayOfNumberOnly from .array_test import ArrayTest from .capitalization import Capitalization -from .cat import Cat from .category import Category from .class_model import ClassModel from .client import Client -from .dog import Dog from .enum_arrays import EnumArrays from .enum_class import EnumClass from .enum_test import EnumTest @@ -50,3 +48,5 @@ from .read_only_first import ReadOnlyFirst from .special_model_name import SpecialModelName from .tag import Tag from .user import User +from .cat import Cat +from .dog import Dog diff --git a/samples/client/petstore/python/petstore_api/models/outer_boolean.py b/samples/client/petstore/python/petstore_api/models/outer_boolean.py index c3d04c856be..8d2e12e9210 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_boolean.py +++ b/samples/client/petstore/python/petstore_api/models/outer_boolean.py @@ -21,22 +21,28 @@ class OuterBoolean(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + + } + + attribute_map = { + + } + def __init__(self): """ OuterBoolean - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. """ - self.swagger_types = { - - } - self.attribute_map = { - - } def to_dict(self): diff --git a/samples/client/petstore/python/petstore_api/models/outer_composite.py b/samples/client/petstore/python/petstore_api/models/outer_composite.py index 8861eb354d5..f8faa39bc3e 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python/petstore_api/models/outer_composite.py @@ -21,30 +21,42 @@ class OuterComposite(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'my_number': 'OuterNumber', + 'my_string': 'OuterString', + 'my_boolean': 'OuterBoolean' + } + + attribute_map = { + 'my_number': 'my_number', + 'my_string': 'my_string', + 'my_boolean': 'my_boolean' + } + def __init__(self, my_number=None, my_string=None, my_boolean=None): """ OuterComposite - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. """ - self.swagger_types = { - 'my_number': 'OuterNumber', - 'my_string': 'OuterString', - 'my_boolean': 'OuterBoolean' - } - self.attribute_map = { - 'my_number': 'my_number', - 'my_string': 'my_string', - 'my_boolean': 'my_boolean' - } + self._my_number = None + self._my_string = None + self._my_boolean = None - self._my_number = my_number - self._my_string = my_string - self._my_boolean = my_boolean + if my_number is not None: + self.my_number = my_number + if my_string is not None: + self.my_string = my_string + if my_boolean is not None: + self.my_boolean = my_boolean @property def my_number(self): diff --git a/samples/client/petstore/python/petstore_api/models/outer_number.py b/samples/client/petstore/python/petstore_api/models/outer_number.py index 93087bff27c..946e0ab0690 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_number.py +++ b/samples/client/petstore/python/petstore_api/models/outer_number.py @@ -21,22 +21,28 @@ class OuterNumber(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + + } + + attribute_map = { + + } + def __init__(self): """ OuterNumber - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. """ - self.swagger_types = { - - } - self.attribute_map = { - - } def to_dict(self): diff --git a/samples/client/petstore/python/petstore_api/models/outer_string.py b/samples/client/petstore/python/petstore_api/models/outer_string.py index dab30f6aca7..a92ba3984c9 100644 --- a/samples/client/petstore/python/petstore_api/models/outer_string.py +++ b/samples/client/petstore/python/petstore_api/models/outer_string.py @@ -21,22 +21,28 @@ class OuterString(object): NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ + + + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + + } + + attribute_map = { + + } + def __init__(self): """ OuterString - a model defined in Swagger - - :param dict swaggerTypes: The key is attribute name - and the value is attribute type. - :param dict attributeMap: The key is attribute name - and the value is json key in definition. """ - self.swagger_types = { - - } - self.attribute_map = { - - } def to_dict(self):