-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_doc_example.mustache
37 lines (33 loc) · 1.5 KB
/
api_doc_example.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
```python
import {{{packageName}}}
{{#vendorExtensions.x-py-example-import}}
{{{.}}}
{{/vendorExtensions.x-py-example-import}}
from {{{packageName}}}.rest import ApiException
from pprint import pprint
{{> python_doc_auth_partial}}
# Enter a context with an instance of the 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}}
{{/allParams}}
try:
{{#summary}}
# {{{.}}}
{{/summary}}
{{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}})
{{#returnType}}
print("The response of {{classname}}->{{operationId}}:\n")
pprint(api_response)
{{/returnType}}
except Exception as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
```
{{#vendorExtensions.x-py-postponed-example-imports.size}}
{{#vendorExtensions.x-py-postponed-example-imports}}
{{{.}}}
{{/vendorExtensions.x-py-postponed-example-imports}}
{{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-example-imports.size}}