diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a596d1c4437..1af34624389 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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/ + ``` + - You may find it helpful to ignore fileMode changes with git: `git -c core.fileMode=false ` - 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) diff --git a/modules/swagger-codegen/src/main/resources/python/asyncio/rest.mustache b/modules/swagger-codegen/src/main/resources/python/asyncio/rest.mustache index 39003abfbfd..92482458f3a 100644 --- a/modules/swagger-codegen/src/main/resources/python/asyncio/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/asyncio/rest.mustache @@ -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, @@ -110,7 +105,8 @@ class RESTClientObject(object): "method": method, "url": url, "timeout": timeout, - "headers": headers + "headers": headers, + "proxy": self.proxy, } if query_params: diff --git a/samples/client/petstore/python-asyncio/.swagger-codegen/VERSION b/samples/client/petstore/python-asyncio/.swagger-codegen/VERSION index e3c58351672..be9d3ebd547 100644 --- a/samples/client/petstore/python-asyncio/.swagger-codegen/VERSION +++ b/samples/client/petstore/python-asyncio/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.9-SNAPSHOT +2.4.13-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-asyncio/petstore_api/rest.py b/samples/client/petstore/python-asyncio/petstore_api/rest.py index 69d87b282c6..4ba9ba7a422 100644 --- a/samples/client/petstore/python-asyncio/petstore_api/rest.py +++ b/samples/client/petstore/python-asyncio/petstore_api/rest.py @@ -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, @@ -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: