forked from loafle/openapi-generator-original
handle composed schemas in InlineModelResolver (#2112)
* handle composed schemas in InlineModelResolver * fix unit test -> TestUtils.parseSpec * update samples * fix samples * update samples * update samples * add new files
This commit is contained in:
committed by
William Cheng
parent
7eb2be9c99
commit
ee43cc1520
@@ -48,10 +48,12 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
from petstore_api.models.array_test import ArrayTest
|
||||
from petstore_api.models.capitalization import Capitalization
|
||||
from petstore_api.models.cat import Cat
|
||||
from petstore_api.models.cat_all_of import CatAllOf
|
||||
from petstore_api.models.category import Category
|
||||
from petstore_api.models.class_model import ClassModel
|
||||
from petstore_api.models.client import Client
|
||||
from petstore_api.models.dog import Dog
|
||||
from petstore_api.models.dog_all_of import DogAllOf
|
||||
from petstore_api.models.enum_arrays import EnumArrays
|
||||
from petstore_api.models.enum_class import EnumClass
|
||||
from petstore_api.models.enum_test import EnumTest
|
||||
|
||||
@@ -29,10 +29,12 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
from petstore_api.models.array_test import ArrayTest
|
||||
from petstore_api.models.capitalization import Capitalization
|
||||
from petstore_api.models.cat import Cat
|
||||
from petstore_api.models.cat_all_of import CatAllOf
|
||||
from petstore_api.models.category import Category
|
||||
from petstore_api.models.class_model import ClassModel
|
||||
from petstore_api.models.client import Client
|
||||
from petstore_api.models.dog import Dog
|
||||
from petstore_api.models.dog_all_of import DogAllOf
|
||||
from petstore_api.models.enum_arrays import EnumArrays
|
||||
from petstore_api.models.enum_class import EnumClass
|
||||
from petstore_api.models.enum_test import EnumTest
|
||||
|
||||
112
samples/client/petstore/python/petstore_api/models/cat_all_of.py
Normal file
112
samples/client/petstore/python/petstore_api/models/cat_all_of.py
Normal file
@@ -0,0 +1,112 @@
|
||||
# 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
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class CatAllOf(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 = {
|
||||
'declawed': 'bool'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'declawed': 'declawed'
|
||||
}
|
||||
|
||||
def __init__(self, declawed=None): # noqa: E501
|
||||
"""CatAllOf - a model defined in OpenAPI""" # noqa: E501
|
||||
|
||||
self._declawed = None
|
||||
self.discriminator = None
|
||||
|
||||
if declawed is not None:
|
||||
self.declawed = declawed
|
||||
|
||||
@property
|
||||
def declawed(self):
|
||||
"""Gets the declawed of this CatAllOf. # noqa: E501
|
||||
|
||||
|
||||
:return: The declawed of this CatAllOf. # noqa: E501
|
||||
:rtype: bool
|
||||
"""
|
||||
return self._declawed
|
||||
|
||||
@declawed.setter
|
||||
def declawed(self, declawed):
|
||||
"""Sets the declawed of this CatAllOf.
|
||||
|
||||
|
||||
:param declawed: The declawed of this CatAllOf. # noqa: E501
|
||||
:type: bool
|
||||
"""
|
||||
|
||||
self._declawed = declawed
|
||||
|
||||
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, CatAllOf):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
||||
112
samples/client/petstore/python/petstore_api/models/dog_all_of.py
Normal file
112
samples/client/petstore/python/petstore_api/models/dog_all_of.py
Normal file
@@ -0,0 +1,112 @@
|
||||
# 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
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class DogAllOf(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 = {
|
||||
'breed': 'str'
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'breed': 'breed'
|
||||
}
|
||||
|
||||
def __init__(self, breed=None): # noqa: E501
|
||||
"""DogAllOf - a model defined in OpenAPI""" # noqa: E501
|
||||
|
||||
self._breed = None
|
||||
self.discriminator = None
|
||||
|
||||
if breed is not None:
|
||||
self.breed = breed
|
||||
|
||||
@property
|
||||
def breed(self):
|
||||
"""Gets the breed of this DogAllOf. # noqa: E501
|
||||
|
||||
|
||||
:return: The breed of this DogAllOf. # noqa: E501
|
||||
:rtype: str
|
||||
"""
|
||||
return self._breed
|
||||
|
||||
@breed.setter
|
||||
def breed(self, breed):
|
||||
"""Sets the breed of this DogAllOf.
|
||||
|
||||
|
||||
:param breed: The breed of this DogAllOf. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
|
||||
self._breed = breed
|
||||
|
||||
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, DogAllOf):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
return not self == other
|
||||
Reference in New Issue
Block a user