forked from loafle/openapi-generator-original
Add to_str method in python client and add test cases.
This commit is contained in:
@@ -16,6 +16,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
|
||||
|
||||
class Category(object):
|
||||
@@ -61,12 +63,35 @@ class Category(object):
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'
|
||||
.format(prop=p, val=self.__dict__[p]))
|
||||
def to_dict(self):
|
||||
"""
|
||||
Return model properties dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__,
|
||||
props=' '.join(properties))
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Return model properties str
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
@@ -16,6 +16,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
|
||||
|
||||
class Order(object):
|
||||
@@ -111,12 +113,35 @@ class Order(object):
|
||||
def complete(self, complete):
|
||||
self._complete = complete
|
||||
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'
|
||||
.format(prop=p, val=self.__dict__[p]))
|
||||
def to_dict(self):
|
||||
"""
|
||||
Return model properties dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__,
|
||||
props=' '.join(properties))
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Return model properties str
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
@@ -16,6 +16,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
|
||||
|
||||
class Pet(object):
|
||||
@@ -111,12 +113,35 @@ class Pet(object):
|
||||
)
|
||||
self._status = status
|
||||
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'
|
||||
.format(prop=p, val=self.__dict__[p]))
|
||||
def to_dict(self):
|
||||
"""
|
||||
Return model properties dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__,
|
||||
props=' '.join(properties))
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Return model properties str
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
@@ -16,6 +16,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
|
||||
|
||||
class Tag(object):
|
||||
@@ -61,12 +63,35 @@ class Tag(object):
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'
|
||||
.format(prop=p, val=self.__dict__[p]))
|
||||
def to_dict(self):
|
||||
"""
|
||||
Return model properties dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__,
|
||||
props=' '.join(properties))
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Return model properties str
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
@@ -16,6 +16,8 @@ Copyright 2015 SmartBear Software
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from pprint import pformat
|
||||
from six import iteritems
|
||||
|
||||
|
||||
class User(object):
|
||||
@@ -127,12 +129,35 @@ class User(object):
|
||||
def user_status(self, user_status):
|
||||
self._user_status = user_status
|
||||
|
||||
def __repr__(self):
|
||||
properties = []
|
||||
for p in self.__dict__:
|
||||
if p != 'swaggerTypes' and p != 'attributeMap':
|
||||
properties.append('{prop}={val!r}'
|
||||
.format(prop=p, val=self.__dict__[p]))
|
||||
def to_dict(self):
|
||||
"""
|
||||
Return model properties dict
|
||||
"""
|
||||
result = {}
|
||||
|
||||
return '<{name} {props}>'.format(name=__name__,
|
||||
props=' '.join(properties))
|
||||
for name, prop in iteritems(self.__dict__):
|
||||
if name == "attribute_map" or name == "swagger_types":
|
||||
continue
|
||||
if isinstance(prop, list):
|
||||
result[name[1:]] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
prop
|
||||
))
|
||||
elif hasattr(prop, "to_dict"):
|
||||
result[name[1:]] = prop.to_dict()
|
||||
else:
|
||||
result[name[1:]] = prop
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""
|
||||
Return model properties str
|
||||
"""
|
||||
return pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
For `print` and `pprint`
|
||||
"""
|
||||
return self.to_str()
|
||||
|
||||
Reference in New Issue
Block a user