OpenAPITools / OpenAPITools/openapi-generator

[BUG] [python] generator version > 7.0.0-beta generate broken code for youtrack.

Open
#17,910 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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? (I tested on latest docker image)
  • 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

I trying to generate python client library for youtrack. I am using docker image, and python generator. The command that i use to generate client is following:

docker run --rm -v $PWD:/local openapitools/openapi-generator-cli:v<version> generate -i https://<host>/api/openapi.json -g python -o /local/oclient

Then I install the client using:

sudo python3 setup.py install

Then I try to use it:

python3
import openapi_client

both for python and python-pedantic-v1 generators, I have following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/__init__.py", line 20, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/api/__init__.py", line 4, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/api/default_api.py", line 28, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/__init__.py", line 18, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/activity_cursor_page.py", line 23, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/activity_item.py", line 24, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/filter_field.py", line 96, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/custom_filter_field.py", line 23, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/custom_field.py", line 113, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/custom_field_defaults.py", line 104, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/build_bundle_custom_field_defaults.py", line 23, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/build_bundle.py", line 23, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/base_bundle.py", line 23, in <module>
  File "/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/bundle.py", line 99, in <module>
ImportError: cannot import name 'BaseBundle' from partially initialized module 'openapi_client.models.base_bundle' (most likely due to a circular import) (/usr/local/lib/python3.10/dist-packages/openapi_client-1.0.0-py3.10.egg/openapi_client/models/base_bundle.py)
>>> 

Then I start downgrade generator and find that v6.5, v7.0.0-beta works fine.

openapi-generator version

Bug exists in: > v7.0.0-beta

OpenAPI declaration file content or url

openapi.json

Generation Details
Steps to reproduce

Just generate python client code, and import it.

Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the attached openapi.json and the Docker generation command, comparing v7.0.0-beta with later versions. Inspect the generated imports in openapi_client/models/bundle.py and base_bundle.py, along with the traceback's related model files. Done means the generated Python client imports without the circular-import error and the regression is covered by an appropriate generator test.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.