forked from loafle/openapi-generator-original
Add additionalProperties handling in python code genrator by adding dictionary handling in model's to_dict() method
This commit is contained in:
parent
a9ab8a6e98
commit
ab39eff8a1
@ -95,6 +95,11 @@ class {{classname}}(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -114,14 +119,14 @@ class {{classname}}(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -106,6 +106,11 @@ class Category(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -125,14 +130,14 @@ class Category(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -212,6 +212,11 @@ class Order(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -231,14 +236,14 @@ class Order(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -212,6 +212,11 @@ class Pet(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -231,14 +236,14 @@ class Pet(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -106,6 +106,11 @@ class Tag(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -125,14 +130,14 @@ class Tag(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
@ -256,6 +256,11 @@ class User(object):
|
|||||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||||
value
|
value
|
||||||
))
|
))
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
result[attr] = dict(map(
|
||||||
|
lambda (k, v): (k, v.to_dict()) if hasattr(v, "to_dict") else (k, v),
|
||||||
|
value.iteritems()
|
||||||
|
))
|
||||||
elif hasattr(value, "to_dict"):
|
elif hasattr(value, "to_dict"):
|
||||||
result[attr] = value.to_dict()
|
result[attr] = value.to_dict()
|
||||||
else:
|
else:
|
||||||
@ -275,14 +280,14 @@ class User(object):
|
|||||||
"""
|
"""
|
||||||
return self.to_str()
|
return self.to_str()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are equal
|
Returns true if both objects are equal
|
||||||
"""
|
"""
|
||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""
|
"""
|
||||||
Returns true if both objects are not equal
|
Returns true if both objects are not equal
|
||||||
"""
|
"""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
Loading…
x
Reference in New Issue
Block a user