Feature/23032 alternative
Closed
AN
5mo ago+59235+59235+01234567890123456789012345678901234567890123456789-14-14-01234567890123456789
Alternative solution to the #23032 where sync methods do not use coroutine but instead they share a common code with async methods.
PR checklist
- [ X ] Read the contribution guidelines.
- [ X ] Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
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. - [ X ] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
@cbornet (2017/09) @tomplus (2018/10) @krjakbrjak (2023/02) @fa0311 (2023/10) @multani (2023/10)
Summary by cubic
Adds supportHttpxSync to the Python httpx generator to create synchronous _sync variants for each API method in the same class, using a real httpx.Client (no coroutine wrapping). This exposes both async and blocking methods without a separate library.
-
New Features
- New
supportHttpxSyncoption in the Python generator (only forhttpx; ignored otherwise with a warning). - Generates
_sync,_sync_with_http_info, and_sync_without_preload_contentalongside async methods. ApiClientaddscall_api_sync(), a sync context manager (__enter__/__exit__), andclose_sync().httpxREST layer adds a dedicatedhttpx.Client,request_sync(),close_sync(), andRESTResponse.read_sync().- Docs updated, new petstore sample (
bin/configs/python-httpx-sync.yamlandsamples/.../python-httpx-sync), and CI workflows include the sample.
- New
-
Migration
- Enable with
additionalProperties.supportHttpxSync=truewhen generating a Python client withlibrary: httpx. - Async methods are unchanged; call
method_sync(...)for blocking usage.
- Enable with