forked from loafle/openapi-generator-original
Support models with multi-level hierarchy (via roxspring) (#4503)
* Example of broken multi-level hierarchy * Support for multiple levels of hierarchy in model objects * Support for multiple levels of hierarchy in generators * Regenerated samples * Temporarily skip scalaz sample verification, which is having issue with Java version in CI container * Re-enable scalaz in verify samples Co-authored-by: Rob Oxspring <roxspring@imapmail.org>
This commit is contained in:
committed by
William Cheng
parent
daec02b8c5
commit
376e419d0b
@@ -46,6 +46,8 @@ from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
from petstore_api.models.array_test import ArrayTest
|
||||
from petstore_api.models.big_cat import BigCat
|
||||
from petstore_api.models.big_cat_all_of import BigCatAllOf
|
||||
from petstore_api.models.capitalization import Capitalization
|
||||
from petstore_api.models.cat import Cat
|
||||
from petstore_api.models.cat_all_of import CatAllOf
|
||||
|
||||
@@ -27,6 +27,8 @@ from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
from petstore_api.models.array_test import ArrayTest
|
||||
from petstore_api.models.big_cat import BigCat
|
||||
from petstore_api.models.big_cat_all_of import BigCatAllOf
|
||||
from petstore_api.models.capitalization import Capitalization
|
||||
from petstore_api.models.cat import Cat
|
||||
from petstore_api.models.cat_all_of import CatAllOf
|
||||
|
||||
@@ -44,7 +44,8 @@ class Animal(object):
|
||||
|
||||
discriminator_value_class_map = {
|
||||
'Dog': 'Dog',
|
||||
'Cat': 'Cat'
|
||||
'Cat': 'Cat',
|
||||
'BigCat': 'BigCat'
|
||||
}
|
||||
|
||||
def __init__(self, class_name=None, color='red', local_vars_configuration=None): # noqa: E501
|
||||
|
||||
126
samples/client/petstore/python/petstore_api/models/big_cat.py
Normal file
126
samples/client/petstore/python/petstore_api/models/big_cat.py
Normal file
@@ -0,0 +1,126 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.configuration import Configuration
|
||||
|
||||
|
||||
class BigCat(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
"""
|
||||
Attributes:
|
||||
openapi_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.
|
||||
"""
|
||||
openapi_types = {
|
||||
'kind': 'str'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'kind': 'kind'
|
||||
}
|
||||
|
||||
def __init__(self, kind=None, local_vars_configuration=None): # noqa: E501
|
||||
"""BigCat - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
|
||||
self._kind = None
|
||||
self.discriminator = None
|
||||
|
||||
if kind is not None:
|
||||
self.kind = kind
|
||||
|
||||
@property
|
||||
def kind(self):
|
||||
"""Gets the kind of this BigCat. # noqa: E501
|
||||
|
||||
|
||||
:return: The kind of this BigCat. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._kind
|
||||
|
||||
@kind.setter
|
||||
def kind(self, kind):
|
||||
"""Sets the kind of this BigCat.
|
||||
|
||||
|
||||
:param kind: The kind of this BigCat. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
allowed_values = ["lions", "tigers", "leopards", "jaguars"] # noqa: E501
|
||||
if self.local_vars_configuration.client_side_validation and kind not in allowed_values: # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `kind` ({0}), must be one of {1}" # noqa: E501
|
||||
.format(kind, allowed_values)
|
||||
)
|
||||
|
||||
self._kind = kind
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.openapi_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, BigCat):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, BigCat):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
||||
@@ -0,0 +1,126 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
from petstore_api.configuration import Configuration
|
||||
|
||||
|
||||
class BigCatAllOf(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
|
||||
"""
|
||||
Attributes:
|
||||
openapi_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.
|
||||
"""
|
||||
openapi_types = {
|
||||
'kind': 'str'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'kind': 'kind'
|
||||
}
|
||||
|
||||
def __init__(self, kind=None, local_vars_configuration=None): # noqa: E501
|
||||
"""BigCatAllOf - a model defined in OpenAPI""" # noqa: E501
|
||||
if local_vars_configuration is None:
|
||||
local_vars_configuration = Configuration()
|
||||
self.local_vars_configuration = local_vars_configuration
|
||||
|
||||
self._kind = None
|
||||
self.discriminator = None
|
||||
|
||||
if kind is not None:
|
||||
self.kind = kind
|
||||
|
||||
@property
|
||||
def kind(self):
|
||||
"""Gets the kind of this BigCatAllOf. # noqa: E501
|
||||
|
||||
|
||||
:return: The kind of this BigCatAllOf. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._kind
|
||||
|
||||
@kind.setter
|
||||
def kind(self, kind):
|
||||
"""Sets the kind of this BigCatAllOf.
|
||||
|
||||
|
||||
:param kind: The kind of this BigCatAllOf. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
allowed_values = ["lions", "tigers", "leopards", "jaguars"] # noqa: E501
|
||||
if self.local_vars_configuration.client_side_validation and kind not in allowed_values: # noqa: E501
|
||||
raise ValueError(
|
||||
"Invalid value for `kind` ({0}), must be one of {1}" # noqa: E501
|
||||
.format(kind, allowed_values)
|
||||
)
|
||||
|
||||
self._kind = kind
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
result = {}
|
||||
|
||||
for attr, _ in six.iteritems(self.openapi_types):
|
||||
value = getattr(self, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
||||
value
|
||||
))
|
||||
elif hasattr(value, "to_dict"):
|
||||
result[attr] = value.to_dict()
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0], item[1].to_dict())
|
||||
if hasattr(item[1], "to_dict") else item,
|
||||
value.items()
|
||||
))
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return pprint.pformat(self.to_dict())
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
return self.to_str()
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Returns true if both objects are equal"""
|
||||
if not isinstance(other, BigCatAllOf):
|
||||
return False
|
||||
|
||||
return self.to_dict() == other.to_dict()
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
if not isinstance(other, BigCatAllOf):
|
||||
return True
|
||||
|
||||
return self.to_dict() != other.to_dict()
|
||||
Reference in New Issue
Block a user