OpenAPITools / OpenAPITools/openapi-generator

[BUG][Python] Syntax Error when importing generated library

Open
#18,030 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?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

Similar error as #17447, tested on both latest stable version 7.3.0 and latest master branch commit.

openapi-generator version

7.3.0

OpenAPI declaration file content or url

https://github.com/Endgrate/OpenAPI

Generation Details
Steps to reproduce

Copy OpenAPI spec

Run

openapi-generator-cli generate -g python -o test --additional-properties=projectName=endgrate,packageName=endgrate --openapi-normalizer SET_TAGS_FOR_ALL_OPERATIONS=endgrate -i OpenAPI/openapi.yaml

Install

pip install -e test

Import in Python

import endgrate

Gives:

line 26
    from endgrate.models.dict[str,_configuration_callback_schema_passthrough_schemas_value] import Dict[str, ConfigurationCallbackSchemaPassthroughSchemasValue]
                             ^
SyntaxError: invalid syntax
Related issues/PRs

#17447, seems like #17659 did not handle all edge cases? Does this have to do with beta support for OpenAPI 3.1?

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

Start by running the stated openapi-generator command with OpenAPI/openapi.yaml, then install the generated test package and reproduce the import failure. Inspect how the Python generator turns the schema into the generated model import shown in the traceback; done means the generated library installs and import endgrate completes without a SyntaxError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.