[Python] 5094 followup - Reduce redundancy in docs (#5161)

* Reduce redundancy in python docs

This is a followup to PR #5094, which had a few unresolved comments at
merge time. This reduces the amount of redundant lines in the api
example doc templates, and ensures that referenced Configuration objects
are actually instantiated.

* Regenerate samples
This commit is contained in:
Fabian von Feilitzsch
2020-02-06 13:58:17 -08:00
committed by GitHub
parent 197cea3248
commit c943ecfe28
32 changed files with 133 additions and 68 deletions

View File

@@ -23,7 +23,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(api_client)
client_client = petstore_api.Client() # client.Client | client model

View File

@@ -21,7 +21,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.DefaultApi(api_client)

View File

@@ -34,7 +34,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
@@ -86,7 +86,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = True # bool | Input boolean as post body (optional)
@@ -142,7 +142,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
outer_composite_outer_composite = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
@@ -198,7 +198,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = 3.4 # float | Input number as post body (optional)
@@ -254,7 +254,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = 'body_example' # str | Input string as post body (optional)
@@ -310,7 +310,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
file_schema_test_class_file_schema_test_class = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
@@ -362,7 +362,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
query = 'query_example' # str |
@@ -418,7 +418,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
client_client = petstore_api.Client() # client.Client | client model
@@ -480,6 +480,7 @@ configuration.password = 'YOUR_PASSWORD'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -571,7 +572,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
@@ -647,6 +648,7 @@ configuration.access_token = 'YOUR_BEARER_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -719,7 +721,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
request_body = {'key': 'request_body_example'} # {str: (str,)} | request body
@@ -772,7 +774,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
param = 'param_example' # str | field1
@@ -829,7 +831,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
pipe = ['pipe_example'] # [str] |

View File

@@ -30,6 +30,7 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class

View File

@@ -55,6 +55,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -114,6 +115,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -206,6 +208,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -290,6 +293,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -355,6 +359,7 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -438,6 +443,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -499,6 +505,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -570,6 +577,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -643,6 +651,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class

View File

@@ -26,7 +26,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
@@ -89,6 +89,7 @@ configuration.api_key['api_key'] = 'YOUR_API_KEY'
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
@@ -142,7 +143,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
order_id = 56 # int | ID of pet that needs to be fetched
@@ -198,7 +199,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
order_order = petstore_api.Order() # order.Order | order placed for purchasing the pet

View File

@@ -30,7 +30,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user_user = petstore_api.User() # user.User | Created user object
@@ -83,7 +83,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user_user = [petstore_api.User()] # [user.User] | List of user object
@@ -136,7 +136,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user_user = [petstore_api.User()] # [user.User] | List of user object
@@ -191,7 +191,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be deleted
@@ -245,7 +245,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
@@ -301,7 +301,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The user name for login
@@ -358,7 +358,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
@@ -409,7 +409,7 @@ import petstore_api
from pprint import pprint
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | name that need to be deleted