You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No way to inject custom requests.Session (Django application) #3
I think the issue is due to the fact that the Client class in openapi_python_sdk is using the requests library's default session internally, and doesn't provide a way to inject a custom session. This is because the Client class is using the requests.Session object to manage connection pooling and retries. To fix this, you could try creating a custom requests.Session object and passing it to the Client constructor, like so: client = Client(token=token, session=session). However, I'd like to confirm whether the Client class is designed to accept a custom session object. Can you clarify if the Client class is intended to be extensible in this way?
That’s a great observation, thanks @IlyasFardaouix for the detailed breakdown.
We’re also experimenting with Django on our side, so this kind of feedback is super valuable. The Client isn’t fully designed yet with that level of extensibility in mind, but it’s definitely something we’re considering as we evolve the API.
Also — since you’re quite active on this — if you’d like to put together a small demo showing how to use the library within a Django setup, we’d be happy to review it and potentially publish it officially on our GitHub channels.
Activity
IlyasFardaouix commentedon Mar 19, 2026
I think the issue is due to the fact that the
Clientclass inopenapi_python_sdkis using therequestslibrary's default session internally, and doesn't provide a way to inject a custom session. This is because theClientclass is using therequests.Sessionobject to manage connection pooling and retries. To fix this, you could try creating a customrequests.Sessionobject and passing it to theClientconstructor, like so:client = Client(token=token, session=session). However, I'd like to confirm whether theClientclass is designed to accept a custom session object. Can you clarify if theClientclass is intended to be extensible in this way?francescobianco commentedon Mar 24, 2026
That’s a great observation, thanks @IlyasFardaouix for the detailed breakdown.
We’re also experimenting with Django on our side, so this kind of feedback is super valuable. The Client isn’t fully designed yet with that level of extensibility in mind, but it’s definitely something we’re considering as we evolve the API.
Also — since you’re quite active on this — if you’d like to put together a small demo showing how to use the library within a Django setup, we’d be happy to review it and potentially publish it officially on our GitHub channels.
Let us know if that sounds interesting 👍