[BUG] [python-nextgen] circular ImportError on spec that $ref's a spec which $ref's the prior one
Created by: j-wash-BL
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When attempting the import the generated client, python throws the following stacktrace:
Traceback (most recent call last):
File "[*project root*]\test.py", line 4, in <module>
import geojson
File "[*project root*]\geojson-client\geojson\__init__.py", line 21, in <module>
from geojson.api.geo_json_api import GeoJsonApi
File "[*project root*]\geojson-client\geojson\api\__init__.py", line 6, in <module>
from geojson.api.geo_json_api import GeoJsonApi
File "[*project root*]\geojson-client\geojson\api\geo_json_api.py", line 23, in <module>
from geojson.models.geo_json_geometry import GeoJsonGeometry
File "[*project root*]\geojson-client\geojson\models\__init__.py", line 18, in <module>
from geojson.models.geo_json_geometry import GeoJsonGeometry
File "[*project root*]\geojson-client\geojson\models\geo_json_geometry.py", line 22, in <module>
from geojson.models.geometry_collection import GeometryCollection
File "[*project root*]\geojson-client\geojson\models\geometry_collection.py", line 23, in <module>
from geojson.models.geo_json_geometry import GeoJsonGeometry
ImportError: cannot import name 'GeoJsonGeometry' from partially initialized module 'geojson.models.geo_json_geometry' (most likely due to a circular import) ([*project root*]\geojson-client\geojson\models\geo_json_geometry.py)
A repo that can reproduce the issue can be found here
openapi-generator version
openapitools/openapi-generator-cli:latest on docker, pulled on 1/5/23
OpenAPI declaration file content or url
The spec can be found here
Generation Details
The client is generated using the following docker command in powershell:
docker run --rm -v "${PWD}/:/output" -v "${PWD}:/input" openapitools/openapi-generator-cli:latest generate `
-g python-nextgen `
-i /input/geojson_spec.v1.yml `
-o /output/geojson-client `
--additional-properties=packageName=geojson `
--additional-properties=packageVersion=2.4.5
Steps to reproduce
- Run the above command to generate client
- Install the client package to my interpreter (in my case, a venv) using
pip install -e geojson-client
- Run any python script that attempts to run
import geojson