Skip to content

Commit 7499139

Browse files
committed
docs: add instructions for customizing transport layer and retry logic
1 parent 8866482 commit 7499139

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ resp = client.request(
112112
)
113113
```
114114

115+
### Customizing the Transport Layer
116+
117+
If you need to configure custom retry logic, proxies, or use a different HTTP client (such as passing a `requests.Session` with a custom urllib3 `Retry`), you can inject it directly using the `client` parameter on any SDK class:
118+
119+
```python
120+
from requests.adapters import HTTPAdapter
121+
from urllib3.util.retry import Retry
122+
from openapi_python_sdk import Client
123+
import requests
124+
125+
retry = Retry(total=3)
126+
adapter = HTTPAdapter(max_retries=retry)
127+
128+
session = requests.Session()
129+
session.mount("https://", adapter)
130+
131+
# Pass the custom session to the Client explicitly
132+
client = Client("token", client=session)
133+
```
134+
115135
## Async Usage
116136

117137
The SDK provides `AsyncClient` and `AsyncOauthClient` for use with asynchronous frameworks like FastAPI or `aiohttp`.

0 commit comments

Comments
 (0)