From 61700fd42c5532deadda7af33cd42de88a215d71 Mon Sep 17 00:00:00 2001 From: "Jendrik A. Potyka" Date: Tue, 29 Nov 2022 07:34:32 +0100 Subject: [PATCH] [Python] Fix client legacy generator asyncio README code example (#13336) * fix missing asyncio keywords * update asyncio sample petstore --- .../src/main/resources/python-legacy/common_README.mustache | 4 ++-- samples/client/petstore/python-asyncio/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python-legacy/common_README.mustache b/modules/openapi-generator/src/main/resources/python-legacy/common_README.mustache index cc7e939194e..6052fe3d20b 100644 --- a/modules/openapi-generator/src/main/resources/python-legacy/common_README.mustache +++ b/modules/openapi-generator/src/main/resources/python-legacy/common_README.mustache @@ -9,7 +9,7 @@ from pprint import pprint {{> python_doc_auth_partial}} # Enter a context with an instance of the API client -with {{{packageName}}}.ApiClient(configuration) as api_client: +{{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = {{{packageName}}}.{{{classname}}}(api_client) {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} @@ -17,7 +17,7 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: try: {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} pprint(api_response){{/returnType}} except ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) diff --git a/samples/client/petstore/python-asyncio/README.md b/samples/client/petstore/python-asyncio/README.md index 18a172f82cc..24c9052d3dc 100644 --- a/samples/client/petstore/python-asyncio/README.md +++ b/samples/client/petstore/python-asyncio/README.md @@ -61,14 +61,14 @@ configuration = petstore_api.Configuration( # Enter a context with an instance of the API client -with petstore_api.ApiClient(configuration) as api_client: +async with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = petstore_api.AnotherFakeApi(api_client) body = petstore_api.Client() # Client | client model try: # To test special tags - api_response = api_instance.call_123_test_special_tags(body) + api_response = await api_instance.call_123_test_special_tags(body) pprint(api_response) except ApiException as e: print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)