From 32eafec8b0d57c12f36e4c5e892bc32e4d824fed Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Wed, 9 Jan 2019 20:15:49 -0600 Subject: [PATCH] Python: Update api_doc_example for multiple auth APIs may more than one auth method (for example both an app key and basic auth). This changes the example to only initialize the config option once instead of once per auth method. --- .../src/main/resources/python/api_doc_example.mustache | 6 ++---- .../src/main/resources/python/common_README.mustache | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/api_doc_example.mustache b/modules/openapi-generator/src/main/resources/python/api_doc_example.mustache index 42e0f32bf73c..282bacf69c27 100644 --- a/modules/openapi-generator/src/main/resources/python/api_doc_example.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_doc_example.mustache @@ -4,18 +4,16 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint -{{#hasAuthMethods}}{{#isBasic}} +{{#hasAuthMethods}} +configuration = {{{packageName}}}.Configuration(){{#isBasic}} # Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.username = 'YOUR_USERNAME' configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} # Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}} # create an instance of the API class diff --git a/modules/openapi-generator/src/main/resources/python/common_README.mustache b/modules/openapi-generator/src/main/resources/python/common_README.mustache index f203456f2088..194fb14b5998 100644 --- a/modules/openapi-generator/src/main/resources/python/common_README.mustache +++ b/modules/openapi-generator/src/main/resources/python/common_README.mustache @@ -4,18 +4,16 @@ import time import {{{packageName}}} from {{{packageName}}}.rest import ApiException from pprint import pprint -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}} +configuration = {{{packageName}}}.Configuration(){{#isBasic}} # Configure HTTP basic authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.username = 'YOUR_USERNAME' configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} # Configure API key authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} # Configure OAuth2 access token for authorization: {{{name}}} -configuration = {{{packageName}}}.Configuration() configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}}