-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix python-fastapi
free-form objects mapping and forward ref type hints
#9723
Fix python-fastapi
free-form objects mapping and forward ref type hints
#9723
Conversation
Forward type references will be supported by default from Python 3.10 on only. Until then (and starting with Python 3.7), we can opt in by a __future__ import, cf. https://docs.python.org/3.9/whatsnew/3.7.html?highlight=forward#pep-563-postponed-evaluation-of-annotations
@krjakbrjak As the author of the |
modules/openapi-generator/src/main/resources/python-fastapi/model.mustache
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having recursive definitions is a valid use case. LGTM. Thanks.
@chludwig-haufe I just spotted the following errors in the CI:
Can you please take a look when you've time? |
@chludwig-haufe @wing328 python 3.6 is set as default. Since the dockerfile is already generated and uses 3.7, it makes sense to build the image (which is built only when the tests pass). I opened #9771 (it addresses this issue) |
This PR implements the proposed fixes for #9720 and #9721:
Dict[str, Any]
.from __future__ import annotations
to the model template. (This is supported in Python >= 3.7.)With these changes in place, the generated FastAPI service could actually be started.
Python technical committee: @taxpon, @frol, @mbohlool, @cbornet, @kenjones-cisco, @tomplus, @Jyhess, @arun-nalla, @spacether
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x