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
@@ -127,6 +127,8 @@ Class | Method | HTTP request | Description
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [BigCat](docs/BigCat.md)
|
||||
- [BigCatAllOf](docs/BigCatAllOf.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
|
||||
10
samples/client/petstore/python-asyncio/docs/BigCat.md
Normal file
10
samples/client/petstore/python-asyncio/docs/BigCat.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# BigCat
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**kind** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
10
samples/client/petstore/python-asyncio/docs/BigCatAllOf.md
Normal file
10
samples/client/petstore/python-asyncio/docs/BigCatAllOf.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# BigCatAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**kind** | **str** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
39
samples/client/petstore/python-asyncio/test/test_big_cat.py
Normal file
39
samples/client/petstore/python-asyncio/test/test_big_cat.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.big_cat import BigCat # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
|
||||
class TestBigCat(unittest.TestCase):
|
||||
"""BigCat unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testBigCat(self):
|
||||
"""Test BigCat"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = petstore_api.models.big_cat.BigCat() # noqa: E501
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.big_cat_all_of import BigCatAllOf # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
|
||||
class TestBigCatAllOf(unittest.TestCase):
|
||||
"""BigCatAllOf unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testBigCatAllOf(self):
|
||||
"""Test BigCatAllOf"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = petstore_api.models.big_cat_all_of.BigCatAllOf() # noqa: E501
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user