OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.73k stars 6.56k forks source link

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

Open WilliamHYZhang opened 7 months ago

WilliamHYZhang commented 7 months ago

Bug Report Checklist

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?

jaklaassen-affirm commented 7 months ago

I looked at this a little bit, and I'm not an expert on the code, but my best guess would be something with the 3.1 syntax. My issues depended on a specific combination of oneOf/anyOf, but your schema looks pretty simple.

WilliamHYZhang commented 7 months ago

Yeah, looking again I don't think it has to do with any specific 3.1 syntax...

booxter commented 5 months ago

I am able to reproduce this same failure with the following simple schema: https://github.com/booxter/letsrolld/commit/54ee9ae806f3b736bb6e28cc455f4c433660fe33