feat: Add per-request headers, timeout, and auth overrides to endpoint functions#1416
Open
kwardega-sc wants to merge 2 commits intoopenapi-generators:mainfrom
Open
feat: Add per-request headers, timeout, and auth overrides to endpoint functions#1416kwardega-sc wants to merge 2 commits intoopenapi-generators:mainfrom
kwardega-sc wants to merge 2 commits intoopenapi-generators:mainfrom
Conversation
…t functions Adds optional `headers`, `timeout`, and `auth` keyword arguments to all generated endpoint functions (sync_detailed, asyncio_detailed, sync, asyncio). These are forwarded directly to the underlying httpx `.request()` call, allowing per-request overrides without creating a new client instance or disrupting the shared connection pool. `with_headers()` and `with_timeout()` mutate the original client's underlying httpx client as a side effect and cause the returned client to open a new connection pool on first use, making them unsafe for runtime per-request use (especially in concurrent async code). This change provides the correct alternative. Known limitation: client-level headers cannot be removed for a single request; they can only be overridden with a different value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds optional
headers,timeout, andauthkeyword arguments to all generated endpoint functions (sync_detailed, asyncio_detailed, sync, asyncio). These are forwarded directly to the underlying httpx.request()call, allowing per-request overrides without creating a new client instance or disrupting the shared connection pool.with_headers()andwith_timeout()mutate the original client's underlying httpx client as a side effect and cause the returned client to open a new connection pool on first use, making them unsafe for runtime per-request use (especially in concurrent async code).