Skip to content

fix proxy usage for python-asyncio, fixes #9995 #10045

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ To add test cases (optional) covering the change in the code generator, please r

To test the templates, please perform the following:
- Update the [Petstore](http://petstore.swagger.io/) sample by running the shell script under `bin` folder. For example, run `./bin/ruby-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/ruby) For Windows, the batch files can be found under `bin\windows` folder. (If you find that there are new files generated or unexpected changes as a result of the update, that's not unusual as the test cases are added to the OpenAPI/Swagger spec from time to time. If you've questions or concerns, please open a ticket to start a discussion)
- To run one of these shell scripts in docker, you can:
```
# From the root of this repo
docker build -t swagger-codegen .
docker run --rm -v $PWD:/cwd -v $PWD/samples:/opt/swagger-codegen/samples swagger-codegen /cwd/bin/<bin file>
```
- You may find it helpful to ignore fileMode changes with git: `git -c core.fileMode=false <git command>`
- Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests)
- You might need a locally running `petstore` server, which can be started with:
```
docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore
```
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,10 @@ class RESTClientObject(object):
)

# https pool manager
if configuration.proxy:
self.pool_manager = aiohttp.ClientSession(
connector=connector,
proxy=configuration.proxy
)
else:
self.pool_manager = aiohttp.ClientSession(
connector=connector
)
self.proxy = configuration.proxy
self.pool_manager = aiohttp.ClientSession(
connector=connector
)

async def request(self, method, url, query_params=None, headers=None,
body=None, post_params=None, _preload_content=True,
Expand Down Expand Up @@ -110,7 +105,8 @@ class RESTClientObject(object):
"method": method,
"url": url,
"timeout": timeout,
"headers": headers
"headers": headers,
"proxy": self.proxy,
}

if query_params:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.9-SNAPSHOT
2.4.13-SNAPSHOT
16 changes: 6 additions & 10 deletions samples/client/petstore/python-asyncio/petstore_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,10 @@ def __init__(self, configuration, pools_size=4, maxsize=4):
)

# https pool manager
if configuration.proxy:
self.pool_manager = aiohttp.ClientSession(
connector=connector,
proxy=configuration.proxy
)
else:
self.pool_manager = aiohttp.ClientSession(
connector=connector
)
self.proxy = configuration.proxy
self.pool_manager = aiohttp.ClientSession(
connector=connector
)

async def request(self, method, url, query_params=None, headers=None,
body=None, post_params=None, _preload_content=True,
Expand Down Expand Up @@ -119,7 +114,8 @@ async def request(self, method, url, query_params=None, headers=None,
"method": method,
"url": url,
"timeout": timeout,
"headers": headers
"headers": headers,
"proxy": self.proxy,
}

if query_params:
Expand Down