Fix 18271: Circular imports on AllOf generation with REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=True (#18272)

* fix issue 18271

* the same update for python-pydantic-v1

* add test

* update samples

* update samples

* put properties under allOf for python client tests

* update samples

* add a test in test model
This commit is contained in:
Zishun (Zack) Wei
2024-04-08 19:01:01 +08:00
committed by GitHub
parent 2c663561ef
commit 453facc81c
56 changed files with 2246 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
import datetime
from petstore_api.models.all_of_super_model import AllOfSuperModel # noqa: E501
class TestAllOfSuperModel(unittest.TestCase):
"""AllOfSuperModel unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> AllOfSuperModel:
"""Test AllOfSuperModel
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AllOfSuperModel`
"""
model = AllOfSuperModel() # noqa: E501
if include_optional:
return AllOfSuperModel(
name = ''
)
else:
return AllOfSuperModel(
)
"""
def testAllOfSuperModel(self):
"""Test AllOfSuperModel"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,61 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
import datetime
from petstore_api.models.circular_all_of_ref import CircularAllOfRef # noqa: E501
class TestCircularAllOfRef(unittest.TestCase):
"""CircularAllOfRef unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> CircularAllOfRef:
"""Test CircularAllOfRef
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `CircularAllOfRef`
"""
model = CircularAllOfRef() # noqa: E501
if include_optional:
return CircularAllOfRef(
second_circular_all_of_ref = [
petstore_api.models.second_circular_all_of_ref.SecondCircularAllOfRef(
circular_all_of_ref = [
petstore_api.models.circular_all_of_ref.CircularAllOfRef(
second_circular_all_of_ref = [
petstore_api.models.second_circular_all_of_ref.SecondCircularAllOfRef()
], )
], )
],
name = ''
)
else:
return CircularAllOfRef(
)
"""
def testCircularAllOfRef(self):
"""Test CircularAllOfRef"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,58 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
import datetime
from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef # noqa: E501
class TestSecondCircularAllOfRef(unittest.TestCase):
"""SecondCircularAllOfRef unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> SecondCircularAllOfRef:
"""Test SecondCircularAllOfRef
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `SecondCircularAllOfRef`
"""
model = SecondCircularAllOfRef() # noqa: E501
if include_optional:
return SecondCircularAllOfRef(
circular_all_of_ref = [
petstore_api.models.circular_all_of_ref.CircularAllOfRef(
second_circular_all_of_ref = [
petstore_api.models.second_circular_all_of_ref.SecondCircularAllOfRef()
], )
],
name = ''
)
else:
return SecondCircularAllOfRef(
)
"""
def testSecondCircularAllOfRef(self):
"""Test SecondCircularAllOfRef"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()