Skip to content

generated client doesn't support proxies #773

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

Closed
leifwalsh opened this issue Jun 27, 2023 · 3 comments
Closed

generated client doesn't support proxies #773

leifwalsh opened this issue Jun 27, 2023 · 3 comments
Labels
✨ enhancement New feature or improvement
Milestone

Comments

@leifwalsh
Copy link

Is your feature request related to a problem? Please describe.

The generated client is nice - clean, ergonomic, and lean - but it doesn't provide the full ability to pass arguments through to httpx. In the case I care about right now, I need to pass a proxy configuration to it (and I need to do so in code, I cannot rely on environment variables for an uninteresting reason, which is that I need one application to use different proxies in different places).

Describe the solution you'd like

I believe something like #202 would help, but I'm open to other ideas. It occurs to me that the format of the proxies dict that httpx accepts is actually itself an implementation detail specific to httpx. requests, for example, uses keys like http and https while httpx's proxy keys are http:// and https://.

Describe alternatives you've considered

So far I've customized the client.py.jinja and endpoint_module.py.jinja templates in the obvious way, and it works, but I don't want to be subject to bugs if the templates change in future versions, I'd rather openapi-python-client intentionally support some form of proxy config.

@leifwalsh leifwalsh added the ✨ enhancement New feature or improvement label Jun 27, 2023
@dbanty
Copy link
Collaborator

dbanty commented Jul 3, 2023

Hey @leifwalsh, thanks for opening this issue! Because of the long list of improvements that can be solved with #202, I've finally taking the time to put together an MVP for it. Would you check out #775 and see what you think? I even added a sample of proxies to the generated README—it's not the cleanest thing (you have to set base_url twice), but I'm trying to keep the basics as simple as possible. Any ideas you have to improve the design would be much appreciated!

@leifwalsh
Copy link
Author

Yeah, I think that makes sense to me.

I think client.get_client() reads a little funny. How about get_http_client()?

@dbanty
Copy link
Collaborator

dbanty commented Jul 3, 2023

I think client.get_client() reads a little funny. How about get_http_client()?

Agreed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

2 participants