When generating a python client using the current snapshot of the openapi generator, an circular import occurs when a discriminator is inherited via AllOf.
Bug Report Checklist
ImportError while importing test module '/home/thoerberg/Documents/Work/repositories/vcd_cloudapi/test/test_group.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.10/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
../test/test_group.py:18: in <module>
from vcd_cloudapi.models.group import Group # noqa: E501
../vcd_cloudapi/models/group.py:23: in <module>
from vcd_cloudapi.models.presentation_element import PresentationElement
../vcd_cloudapi/models/presentation_element.py:105: in <module>
from vcd_cloudapi.models.group import Group
E ImportError: cannot import name 'Group' from partially initialized module 'vcd_cloudapi.models.group' (most likely due to a circular import) (/home/thoerberg/Documents/Work/repositories/vcd_cloudapi/vcd_cloudapi/models/group.py)
Description
see above
openapi-generator version
the latest Snapshot/freshly built binary
OpenAPI declaration file content or url
{
"swagger": "2.0",
"info": {
"version": "36.3",
"title": "VMware Cloud Director OpenAPI"
},
"basePath": "/cloudapi",
"tags": [],
"schemes": [
"https"
],
"paths": {},
"definitions": {
"PresentationElement": {
"type": "object",
"required": [
"elementType"
],
"discriminator": "elementType",
"properties": {
"elementType": {
"type": "string"
}
}
},
"Group": {
"allOf": [
{
"$ref": "#/definitions/PresentationElement"
},
{
"type": "object",
"properties": {}
}
]
}
}
}
Generation Details
/opt/jdk11/bin/java -jar /home/thoerberg/Downloads/openapi-generator-cli-7.1.0-20231012.113715-77.jar generate \
-i input.json \
-g python \
-o ...
Suggest a fix
See: PR #16809
When generating a python client using the current snapshot of the openapi generator, an circular import occurs when a discriminator is inherited via AllOf.
Bug Report Checklist
Expected output:
Running tests via
python -m pytest .passesAcutal output:
Description
see above
openapi-generator version
the latest Snapshot/freshly built binary
OpenAPI declaration file content or url
{ "swagger": "2.0", "info": { "version": "36.3", "title": "VMware Cloud Director OpenAPI" }, "basePath": "/cloudapi", "tags": [], "schemes": [ "https" ], "paths": {}, "definitions": { "PresentationElement": { "type": "object", "required": [ "elementType" ], "discriminator": "elementType", "properties": { "elementType": { "type": "string" } } }, "Group": { "allOf": [ { "$ref": "#/definitions/PresentationElement" }, { "type": "object", "properties": {} } ] } } }Generation Details
Suggest a fix
See: PR #16809