[Python] Proxy support in generated Python module #4639

Closed
krmaxwell opened this Issue Jan 24, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@krmaxwell
Contributor

krmaxwell commented Jan 24, 2017

Description

Currently, the generated Python module does not support proxy usage. Is this something in the works? I've cobbled together some modifications to the code but am unsure of the best way to specify the configuration. My current setup uses an environment variable that is automatically detected and used at runtime. Using the requests library would also streamline this greatly.

Swagger-codegen version

2.1.0 but this appears to be the case in master based on https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/python/rest.mustache

Related issues

#4000
#4102

Suggest a Fix

Apart from using requests, I have a patch (locally, not yet submitted as a PR) to detect the environment variable HTTPS_PROXY at runtime. If it exists, I create an additional property for the Configuration() object and call urllib3.ProxyManager() instead of urllib3.PoolManager() in rest.py. I'd appreciate feedback and constructive criticism on this approach.

@wing328 wing328 added this to the v2.2.2 milestone Jan 24, 2017

@wing328

This comment has been minimized.

Show comment
Hide comment
@wing328

wing328 Jan 24, 2017

Contributor

@krmaxwell thanks for reporting the issue and proposing a fix.

For PHP, we've added the proxy-related properties to the configuration class: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php#L144-L178

For Python, I think we can do something similar.

Contributor

wing328 commented Jan 24, 2017

@krmaxwell thanks for reporting the issue and proposing a fix.

For PHP, we've added the proxy-related properties to the configuration class: https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php#L144-L178

For Python, I think we can do something similar.

krmaxwell pushed a commit to krmaxwell/swagger-codegen that referenced this issue Jan 27, 2017

oflebbe added a commit to oflebbe/swagger-codegen that referenced this issue Feb 14, 2017

@wing328

This comment has been minimized.

Show comment
Hide comment
@wing328

wing328 Feb 17, 2017

Contributor

@krmaxwell may I know if you've time to contribute the enhancement? Let me know if you need help with the PR.

Contributor

wing328 commented Feb 17, 2017

@krmaxwell may I know if you've time to contribute the enhancement? Let me know if you need help with the PR.

@wing328 wing328 modified the milestones: Future, v2.2.2 Feb 17, 2017

@wing328 wing328 added the help wanted label Feb 17, 2017

@krmaxwell

This comment has been minimized.

Show comment
Hide comment
@krmaxwell

krmaxwell Mar 6, 2017

Contributor

@wing328 Yes, sorry, I have something cobbled together that I will submit today. I'll need feedback, though, to make sure I'm doing it properly. 😺

Contributor

krmaxwell commented Mar 6, 2017

@wing328 Yes, sorry, I have something cobbled together that I will submit today. I'll need feedback, though, to make sure I'm doing it properly. 😺

krmaxwell pushed a commit to krmaxwell/swagger-codegen that referenced this issue Mar 6, 2017

@wing328 wing328 closed this in 3e3d360 Mar 8, 2017

spr3nk3ls pushed a commit to spr3nk3ls/swagger-codegen that referenced this issue Mar 28, 2017

Add proxy support to fix #4639 (#4946)
* Add proxy support to fix #4639

* Update sample app for testing

* Fix indentation and remove leftover code

* Update sample for new rest template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment