openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open WilliamHYZhang opened this issue 11 months ago • 3 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] 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?

WilliamHYZhang avatar Mar 05 '24 04:03 WilliamHYZhang

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.

jaklaassen-affirm avatar Mar 13 '24 16:03 jaklaassen-affirm

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

WilliamHYZhang avatar Mar 21 '24 19:03 WilliamHYZhang

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

booxter avatar May 05 '24 20:05 booxter