Fix Python codegen in specific additionalProperties case. (#17659)

* Fix Python codegen is specific additionalProperties case.

* Add generated test files.

* Apply fix to AbstractPythonPydanticV1Codegen.java.
This commit is contained in:
Jonathan Klaassen
2024-02-05 06:17:14 -08:00
committed by GitHub
parent 334ddca021
commit 6bcf8cd332
43 changed files with 1514 additions and 6 deletions

View File

@@ -0,0 +1,56 @@
# 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.input_all_of import InputAllOf # noqa: E501
class TestInputAllOf(unittest.TestCase):
"""InputAllOf unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> InputAllOf:
"""Test InputAllOf
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 `InputAllOf`
"""
model = InputAllOf() # noqa: E501
if include_optional:
return InputAllOf(
some_data = {
'key' : petstore_api.models.tag.Tag(
id = 56,
name = '', )
}
)
else:
return InputAllOf(
)
"""
def testInputAllOf(self):
"""Test InputAllOf"""
# 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,56 @@
# 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.property_map import PropertyMap # noqa: E501
class TestPropertyMap(unittest.TestCase):
"""PropertyMap unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> PropertyMap:
"""Test PropertyMap
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 `PropertyMap`
"""
model = PropertyMap() # noqa: E501
if include_optional:
return PropertyMap(
some_data = {
'key' : petstore_api.models.tag.Tag(
id = 56,
name = '', )
}
)
else:
return PropertyMap(
)
"""
def testPropertyMap(self):
"""Test PropertyMap"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()