diff --git a/modules/openapi-generator/src/main/resources/python/api_doc.mustache b/modules/openapi-generator/src/main/resources/python/api_doc.mustache index 32c26d929d1..c16779a5f96 100644 --- a/modules/openapi-generator/src/main/resources/python/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_doc.mustache @@ -18,47 +18,14 @@ Method | HTTP request | Description {{{notes}}}{{/notes}} ### Example -```python -from __future__ import print_function -import time -import {{{packageName}}} -from {{{packageName}}}.rest import ApiException -from pprint import pprint -{{#hasAuthMethods}}{{#authMethods}}{{#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}} - -# create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +{{#hasAuthMethods}}{{#authMethods}} +{{#isBasic}}* Basic Authentication ({{name}}): {{/isBasic }}{{#isApiKey}}* Api Key Authentication ({{name}}): {{/isApiKey }}{{#isOAuth}}* OAuth Authentication ({{name}}): {{/isOAuth }} +{{> api_doc_example }} +{{/authMethods}} {{/hasAuthMethods}} {{^hasAuthMethods}} - -# create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}}() -{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} -{{/allParams}} +{{> api_doc_example }} {{/hasAuthMethods}} - -try: -{{#summary}} # {{{.}}} -{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} - pprint(api_response){{/returnType}} -except ApiException as e: - print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) -``` - ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes 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 new file mode 100644 index 00000000000..42e0f32bf73 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/api_doc_example.mustache @@ -0,0 +1,40 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#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 +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} +{{^hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} +{{/hasAuthMethods}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/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/.openapi-generator/VERSION b/samples/client/petstore/python-asyncio/.openapi-generator/VERSION index c791c986fbb..105bb87d77b 100644 --- a/samples/client/petstore/python-asyncio/.openapi-generator/VERSION +++ b/samples/client/petstore/python-asyncio/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.3-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-asyncio/docs/FakeApi.md b/samples/client/petstore/python-asyncio/docs/FakeApi.md index 3510abda8b7..57cf9937d36 100644 --- a/samples/client/petstore/python-asyncio/docs/FakeApi.md +++ b/samples/client/petstore/python-asyncio/docs/FakeApi.md @@ -353,6 +353,8 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ### Example + +* Basic Authentication (http_basic_test): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-asyncio/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python-asyncio/docs/FakeClassnameTags123Api.md index 34d44991ff9..3180674a077 100644 --- a/samples/client/petstore/python-asyncio/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python-asyncio/docs/FakeClassnameTags123Api.md @@ -15,6 +15,8 @@ To test class name in snake case To test class name in snake case ### Example + +* Api Key Authentication (api_key_query): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-asyncio/docs/PetApi.md b/samples/client/petstore/python-asyncio/docs/PetApi.md index 9b8fd577a52..726db4708d7 100644 --- a/samples/client/petstore/python-asyncio/docs/PetApi.md +++ b/samples/client/petstore/python-asyncio/docs/PetApi.md @@ -21,6 +21,8 @@ Method | HTTP request | Description Add a new pet to the store ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -70,6 +72,8 @@ void (empty response body) Deletes a pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -123,6 +127,8 @@ Finds Pets by status Multiple status values can be provided with comma separated strings ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -175,6 +181,8 @@ Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -227,6 +235,8 @@ Find pet by ID Returns a single pet ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time @@ -279,6 +289,8 @@ Name | Type | Description | Notes Update an existing pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -328,6 +340,8 @@ void (empty response body) Updates a pet in the store with form data ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -381,6 +395,8 @@ void (empty response body) uploads an image ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -435,6 +451,8 @@ Name | Type | Description | Notes uploads an image (required) ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-asyncio/docs/StoreApi.md b/samples/client/petstore/python-asyncio/docs/StoreApi.md index e4d6a7a8885..ab342460f86 100644 --- a/samples/client/petstore/python-asyncio/docs/StoreApi.md +++ b/samples/client/petstore/python-asyncio/docs/StoreApi.md @@ -65,6 +65,8 @@ Returns pet inventories by status Returns a map of status codes to quantities ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-tornado/.openapi-generator/VERSION b/samples/client/petstore/python-tornado/.openapi-generator/VERSION index c791c986fbb..105bb87d77b 100644 --- a/samples/client/petstore/python-tornado/.openapi-generator/VERSION +++ b/samples/client/petstore/python-tornado/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.3-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-tornado/docs/FakeApi.md b/samples/client/petstore/python-tornado/docs/FakeApi.md index 3510abda8b7..57cf9937d36 100644 --- a/samples/client/petstore/python-tornado/docs/FakeApi.md +++ b/samples/client/petstore/python-tornado/docs/FakeApi.md @@ -353,6 +353,8 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ### Example + +* Basic Authentication (http_basic_test): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-tornado/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python-tornado/docs/FakeClassnameTags123Api.md index 34d44991ff9..3180674a077 100644 --- a/samples/client/petstore/python-tornado/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python-tornado/docs/FakeClassnameTags123Api.md @@ -15,6 +15,8 @@ To test class name in snake case To test class name in snake case ### Example + +* Api Key Authentication (api_key_query): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-tornado/docs/PetApi.md b/samples/client/petstore/python-tornado/docs/PetApi.md index 9b8fd577a52..726db4708d7 100644 --- a/samples/client/petstore/python-tornado/docs/PetApi.md +++ b/samples/client/petstore/python-tornado/docs/PetApi.md @@ -21,6 +21,8 @@ Method | HTTP request | Description Add a new pet to the store ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -70,6 +72,8 @@ void (empty response body) Deletes a pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -123,6 +127,8 @@ Finds Pets by status Multiple status values can be provided with comma separated strings ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -175,6 +181,8 @@ Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -227,6 +235,8 @@ Find pet by ID Returns a single pet ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time @@ -279,6 +289,8 @@ Name | Type | Description | Notes Update an existing pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -328,6 +340,8 @@ void (empty response body) Updates a pet in the store with form data ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -381,6 +395,8 @@ void (empty response body) uploads an image ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -435,6 +451,8 @@ Name | Type | Description | Notes uploads an image (required) ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python-tornado/docs/StoreApi.md b/samples/client/petstore/python-tornado/docs/StoreApi.md index e4d6a7a8885..ab342460f86 100644 --- a/samples/client/petstore/python-tornado/docs/StoreApi.md +++ b/samples/client/petstore/python-tornado/docs/StoreApi.md @@ -65,6 +65,8 @@ Returns pet inventories by status Returns a map of status codes to quantities ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python/.openapi-generator/VERSION b/samples/client/petstore/python/.openapi-generator/VERSION index c791c986fbb..105bb87d77b 100644 --- a/samples/client/petstore/python/.openapi-generator/VERSION +++ b/samples/client/petstore/python/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.3-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index 3510abda8b7..57cf9937d36 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -353,6 +353,8 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ### Example + +* Basic Authentication (http_basic_test): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python/docs/FakeClassnameTags123Api.md index 34d44991ff9..3180674a077 100644 --- a/samples/client/petstore/python/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python/docs/FakeClassnameTags123Api.md @@ -15,6 +15,8 @@ To test class name in snake case To test class name in snake case ### Example + +* Api Key Authentication (api_key_query): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md index 9b8fd577a52..726db4708d7 100644 --- a/samples/client/petstore/python/docs/PetApi.md +++ b/samples/client/petstore/python/docs/PetApi.md @@ -21,6 +21,8 @@ Method | HTTP request | Description Add a new pet to the store ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -70,6 +72,8 @@ void (empty response body) Deletes a pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -123,6 +127,8 @@ Finds Pets by status Multiple status values can be provided with comma separated strings ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -175,6 +181,8 @@ Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -227,6 +235,8 @@ Find pet by ID Returns a single pet ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time @@ -279,6 +289,8 @@ Name | Type | Description | Notes Update an existing pet ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -328,6 +340,8 @@ void (empty response body) Updates a pet in the store with form data ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -381,6 +395,8 @@ void (empty response body) uploads an image ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time @@ -435,6 +451,8 @@ Name | Type | Description | Notes uploads an image (required) ### Example + +* OAuth Authentication (petstore_auth): ```python from __future__ import print_function import time diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md index e4d6a7a8885..ab342460f86 100644 --- a/samples/client/petstore/python/docs/StoreApi.md +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -65,6 +65,8 @@ Returns pet inventories by status Returns a map of status codes to quantities ### Example + +* Api Key Authentication (api_key): ```python from __future__ import print_function import time