mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-07 02:56:09 +00:00
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
@@ -120,10 +120,12 @@ Class | Method | HTTP request | Description
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
|
||||
10
samples/openapi3/client/petstore/python/docs/CatAllOf.md
Normal file
10
samples/openapi3/client/petstore/python/docs/CatAllOf.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# CatAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **bool** | | [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/openapi3/client/petstore/python/docs/DogAllOf.md
Normal file
10
samples/openapi3/client/petstore/python/docs/DogAllOf.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# DogAllOf
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **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)
|
||||
|
||||
|
||||
@@ -42,10 +42,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
|
||||
|
||||
@@ -22,10 +22,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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.cat_all_of import CatAllOf # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
|
||||
class TestCatAllOf(unittest.TestCase):
|
||||
"""CatAllOf unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testCatAllOf(self):
|
||||
"""Test CatAllOf"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = petstore_api.models.cat_all_of.CatAllOf() # 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
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.dog_all_of import DogAllOf # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
|
||||
class TestDogAllOf(unittest.TestCase):
|
||||
"""DogAllOf unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testDogAllOf(self):
|
||||
"""Test DogAllOf"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = petstore_api.models.dog_all_of.DogAllOf() # noqa: E501
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user