-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[python] add async httpx support #22021
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
Conversation
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
|
thanks for the PR.
|
|
cc @cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10) |
6f4a843 to
96594a8
Compare
96594a8 to
9050b8b
Compare
|
I've linked my commits, thanks for noticing! |
sorry please put it on hold we can add it later if that's a demand for it (sync support) |
| @@ -0,0 +1,15 @@ | |||
| generatorName: python | |||
| outputDir: samples/openapi3/client/petstore/python-httpx | |||
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.
please add the new folder to the CI workflow
| additionalProperties.put("tornado", "true"); | ||
| } else if ("httpx".equals(getLibrary())) { | ||
| supportingFiles.add(new SupportingFile("httpx/rest.mustache", packagePath(), "rest.py")); | ||
| additionalProperties.put("asyncio", "true"); |
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.
can you please explain why asyncio (library option) needs to be set to true even for httpx library?
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.
For all request methods in clients higher than RESTClientObject to be async def
like here:
So "asyncio" is actually not only a library option
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.
my take is to refactor it if both asyncio and httpx need the same piece of code
for example, add the tag {{#async}} ....{{/async}} that is enabled by both asyncio and httpx libraries
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.
i agree
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.
btw current library name "asyncio" is a bit misleading
asyncio - part of python stdlib (coros, eventloop and so on), not a client library
aiohttp - 3rd party rest client library
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.
please PM me via Slack if you want to further discussion this
2. hand written tests for python-httpx 3. CI workflow updated
|
please review the build failure when you've time |
|
also I wonder if you can add a simple test to add a pet to the petstore server and get it by id similar to https://github.com/OpenAPITools/openapi-generator/blob/master/samples/openapi3/client/petstore/python/tests/test_pet_api.py#L137 this can ensure requests using httpx work with |
i've just copied hand written tests from plain python and fixed some implementation specific things. So this test is already present |
|
all tests passed. i'll get it merged over the weekend before the upcoming release. thanks for the contribution. have a nice weekend. |
|
Thanks for the contribution @soapun! |
|
@soapun when you've time, can you please PM me via Slack? https://join.slack.com/t/openapi-generator/shared_invite/zt-36ucx4ybl-jYrN6euoYn6zxXNZdldoZA |
* [python] fix OpenAPITools#19255 add async httpx support * update docs * 1. "async" parameter for templates 2. hand written tests for python-httpx 3. CI workflow updated * fix mypy
Add httpx (async) as library for python generator
to fix #19255
PR checklist
Commit all changed files.
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*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)