Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14421
Closed
Open
Issue created Jan 10, 2023 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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
  1. Run the above command to generate client
  2. Install the client package to my interpreter (in my case, a venv) using pip install -e geojson-client
  3. Run any python script that attempts to run import geojson
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking