[python] Cleanup ThreadPool with atexit rather than __del__ (#5094)

* [python] Cleanup ThreadPool with atexit rather than __del__

This removes the `__del__` function from the generated Python client,
and replaces it with a `cleanup` function. When a ThreadPool is created,
the cleanup function is registered with the `atexit` module.

This fixes #5093, where the API client could hang indefinitely at
garbage collection.

* Update petstore examples

* Test to ensure threadpool is cleaned up

* Docs now encourage using the context manager

* Regenerate docs

* Update samples
This commit is contained in:
Fabian von Feilitzsch
2020-01-28 21:58:11 -08:00
committed by GitHub
parent d627282e89
commit 15345e1620
58 changed files with 2850 additions and 2264 deletions

View File

@@ -2,6 +2,7 @@
{{>partial_header}}
from __future__ import absolute_import
import atexit
import datetime
from dateutil.parser import parse
import json
@@ -75,11 +76,19 @@ class ApiClient(object):
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}'
self.client_side_validation = configuration.client_side_validation
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -87,6 +96,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -8,22 +8,26 @@ from pprint import pprint
{{#hasAuthMethods}}
# Defining host is optional and default to {{{basePath}}}
configuration.host = "{{{basePath}}}"
# 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}}
# Enter a context with an instance of the API client
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}}
{{/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}}
# Enter a context with an instance of the API client
with {{{packageName}}}.ApiClient() 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}}
{{/hasAuthMethods}}
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
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:
except ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
```

View File

@@ -8,18 +8,20 @@ from pprint import pprint
{{> python_doc_auth_partial}}
# Defining host is optional and default to {{{basePath}}}
configuration.host = "{{{basePath}}}"
# 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}}
# Enter a context with an instance of the API client
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}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
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:
except ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```
## Documentation for API Endpoints

View File

@@ -7,18 +7,20 @@ from pprint import pprint
{{> python_doc_auth_partial}}
# Defining host is optional and default to {{{basePath}}}
configuration.host = "{{{basePath}}}"
# 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}}
# Enter a context with an instance of the API client
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}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
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 {{{packageName}}}.ApiException as e:
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```
## Documentation for API Endpoints

View File

@@ -3,6 +3,7 @@
from __future__ import absolute_import
import json
import atexit
import mimetypes
from multiprocessing.pool import ThreadPool
import os
@@ -74,11 +75,19 @@ class ApiClient(object):
# Set default User-Agent.
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}'
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -86,6 +95,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -7,51 +7,55 @@ from pprint import pprint
{{#hasAuthMethods}}
# Defining host is optional and default to {{{basePath}}}
configuration.host = "{{{basePath}}}"
# Create an instance of the API class
api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration))
# Enter a context with an instance of the API client
with {{{packageName}}}.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
{{/hasAuthMethods}}
{{^hasAuthMethods}}
# Create an instance of the API class
api_instance = {{{packageName}}}.{{{classname}}}()
# Enter a context with an instance of the API client
with {{{packageName}}}.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
{{/hasAuthMethods}}
{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
{{/optionalParams}}
{{#requiredParams}}
{{^hasMore}}
{{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}
{{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}
{{/optionalParams}}
{{#requiredParams}}
{{^hasMore}}
# example passing only required values which don't have defaults set
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}}
# example passing only required values which don't have defaults set
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}}
pprint(api_response){{/returnType}}
except {{{packageName}}}.ApiException as e:
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/hasMore}}
{{/requiredParams}}
{{#optionalParams}}
{{^hasMore}}
{{/hasMore}}
{{/requiredParams}}
{{#optionalParams}}
{{^hasMore}}
# example passing only required values which don't have defaults set
# and optional values
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}}
# example passing only required values which don't have defaults set
# and optional values
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}}
pprint(api_response){{/returnType}}
except {{{packageName}}}.ApiException as e:
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/hasMore}}
{{/optionalParams}}
{{^requiredParams}}
{{^optionalParams}}
{{/hasMore}}
{{/optionalParams}}
{{^requiredParams}}
{{^optionalParams}}
# example, this endpoint has no required or optional parameters
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}}
# example, this endpoint has no required or optional parameters
try:
{{#summary}} # {{{.}}}
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}}
pprint(api_response){{/returnType}}
except {{{packageName}}}.ApiException as e:
except {{{packageName}}}.ApiException as e:
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
{{/optionalParams}}
{{/requiredParams}}
{{/optionalParams}}
{{/requiredParams}}
```

View File

@@ -54,15 +54,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -23,15 +23,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() 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:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -36,14 +36,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
try:
try:
# creates an XmlItem
api_instance.create_xml_item(xml_item)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
```
@@ -89,14 +91,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -142,14 +146,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
try:
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -195,14 +201,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 3.4 # float | Input number as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -248,14 +256,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -301,13 +311,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
try:
try:
api_instance.test_body_with_file_schema(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -351,14 +363,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
# Enter a context with an instance of the 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 |
body = petstore_api.User() # User |
try:
try:
api_instance.test_body_with_query_params(query, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -405,15 +419,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -466,9 +482,11 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
@@ -483,10 +501,10 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
try:
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -546,9 +564,11 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
# Enter a context with an instance of the 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'] # list[str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
@@ -557,10 +577,10 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # list[str] | Form parameter enum test (string array) (optional) (default to '$')
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
try:
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -614,19 +634,21 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
required_string_group = 56 # int | Required String in group parameters
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
try:
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -675,14 +697,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = {'key': 'param_example'} # dict(str, str) | request body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
param = {'key': 'param_example'} # dict(str, str) | request body
try:
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(param)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -726,15 +750,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
# Enter a context with an instance of the 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
param2 = 'param2_example' # str | field2
try:
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```
@@ -781,17 +807,19 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
pipe = ['pipe_example'] # list[str] |
# Enter a context with an instance of the 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'] # list[str] |
ioutil = ['ioutil_example'] # list[str] |
http = ['http_example'] # list[str] |
url = ['url_example'] # list[str] |
context = ['context_example'] # list[str] |
try:
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e)
```

View File

@@ -31,15 +31,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test class name in snake case
api_response = api_instance.test_classname(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -35,14 +35,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Add a new pet to the store
api_instance.add_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -93,15 +95,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
try:
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -155,15 +159,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # list[str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # list[str] | Status values that need to be considered for filter
try:
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -216,15 +222,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # list[str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # list[str] | Tags to filter by
try:
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -279,15 +287,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
try:
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -339,14 +349,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Update an existing pet
api_instance.update_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -399,16 +411,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
try:
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -460,17 +474,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = '/path/to/file' # file | file to upload (optional)
try:
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -522,17 +538,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = '/path/to/file' # file | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
try:
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -26,14 +26,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -88,14 +90,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
try:
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -138,15 +142,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# Enter a context with an instance of the 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
try:
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -192,15 +198,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
body = petstore_api.Order() # Order | order placed for purchasing the pet
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
body = petstore_api.Order() # Order | order placed for purchasing the pet
try:
try:
# Place an order for a pet
api_response = api_instance.place_order(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -30,14 +30,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = petstore_api.User() # User | Created user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = petstore_api.User() # User | Created user object
try:
try:
# Create user
api_instance.create_user(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -81,14 +83,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -132,14 +136,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -185,14 +191,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete user
api_instance.delete_user(username)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -237,15 +245,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# Enter a context with an instance of the 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.
try:
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -291,16 +301,18 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
# Enter a context with an instance of the 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
password = 'password_example' # str | The password for login in clear text
try:
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -346,13 +358,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
try:
try:
# Logs out current logged in user session
api_instance.logout_user()
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -395,15 +409,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
# Enter a context with an instance of the 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
body = petstore_api.User() # User | Updated user object
try:
try:
# Updated user
api_instance.update_user(username, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -10,6 +10,7 @@
from __future__ import absolute_import
import atexit
import datetime
from dateutil.parser import parse
import json
@@ -80,11 +81,19 @@ class ApiClient(object):
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
self.client_side_validation = configuration.client_side_validation
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -92,6 +101,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -53,15 +53,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
body = petstore_api.Client() # client.Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -22,16 +22,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
body = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -36,15 +36,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body
# 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
api_instance = petstore_api.FakeApi(api_client)
xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# creates an XmlItem
api_instance.create_xml_item(xml_item)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
```
@@ -89,16 +91,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = True # bool | Input boolean as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -143,16 +147,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -197,16 +203,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_enum_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_enum_serialize: %s\n" % e)
```
@@ -251,16 +259,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -305,16 +315,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = 'body_example' # str | Input string as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -359,14 +371,16 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
# 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
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_file_schema(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -409,15 +423,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
body = petstore_api.User() # user.User |
# 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
api_instance = petstore_api.FakeApi(api_client)
query = 'query_example' # str |
body = petstore_api.User() # user.User |
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_query_params(query, body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -463,16 +479,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -517,13 +535,15 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
# 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
api_instance = petstore_api.FakeApi(api_client)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_endpoint_enums_length_one()
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_enums_length_one: %s\n" % e)
```
@@ -579,13 +599,15 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 56 # int | None (optional)
float = 3.4 # float | None (optional)
@@ -596,19 +618,19 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -667,9 +689,11 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
@@ -678,12 +702,12 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -736,28 +760,30 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -805,15 +831,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = {'key': 'param_example'} # {str: (str,)} | request body
# 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
api_instance = petstore_api.FakeApi(api_client)
param = {'key': 'param_example'} # {str: (str,)} | request body
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(param)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -856,16 +884,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
# 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
api_instance = petstore_api.FakeApi(api_client)
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```

View File

@@ -30,16 +30,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
body = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test class name in snake case
api_response = api_instance.test_classname(body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -34,15 +34,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Add a new pet to the store
api_instance.add_pet(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -92,24 +94,26 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Deletes a pet
api_instance.delete_pet(pet_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -162,16 +166,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # [str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # [str] | Status values that need to be considered for filter
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -223,16 +229,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # [str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # [str] | Tags to filter by
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -286,16 +294,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -346,15 +356,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Update an existing pet
api_instance.update_pet(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -406,25 +418,27 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -475,28 +489,30 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# uploads an image
api_response = api_instance.upload_file(pet_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -548,27 +564,29 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -25,15 +25,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# 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
api_instance = petstore_api.StoreApi(api_client)
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -87,15 +89,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -137,16 +141,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# 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
api_instance = petstore_api.StoreApi(api_client)
order_id = 56 # int | ID of pet that needs to be fetched
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -191,16 +197,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
body = petstore_api.Order() # order.Order | order placed for purchasing the pet
# 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
api_instance = petstore_api.StoreApi(api_client)
body = petstore_api.Order() # order.Order | order placed for purchasing the pet
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Place an order for a pet
api_response = api_instance.place_order(body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -29,15 +29,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = petstore_api.User() # user.User | Created user object
# 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
api_instance = petstore_api.UserApi(api_client)
body = petstore_api.User() # user.User | Created user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Create user
api_instance.create_user(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -80,15 +82,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # [user.User] | List of user object
# 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
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # [user.User] | List of user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -131,15 +135,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # [user.User] | List of user object
# 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
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # [user.User] | List of user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -184,15 +190,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be deleted
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Delete user
api_instance.delete_user(username)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -236,16 +244,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -290,17 +300,19 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
password = 'password_example' # str | The password for login in clear text
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The user name for login
password = 'password_example' # str | The password for login in clear text
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -345,14 +357,16 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# 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
api_instance = petstore_api.UserApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
# Logs out current logged in user session
api_instance.logout_user()
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -394,16 +408,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
body = petstore_api.User() # user.User | Updated user object
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | name that need to be deleted
body = petstore_api.User() # user.User | Updated user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Updated user
api_instance.update_user(username, body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -11,6 +11,7 @@
from __future__ import absolute_import
import json
import atexit
import mimetypes
from multiprocessing.pool import ThreadPool
import os
@@ -79,11 +80,19 @@ class ApiClient(object):
# Set default User-Agent.
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -91,6 +100,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -11,6 +11,8 @@ $ nosetests -v
import os
import time
import atexit
import weakref
import unittest
from dateutil.parser import parse
@@ -199,3 +201,17 @@ class ApiClientTests(unittest.TestCase):
model = petstore_api.StringBooleanMap(**model_dict)
result = self.api_client.sanitize_for_serialization(model)
self.assertEqual(result, model_dict)
def test_context_manager_closes_threadpool(self):
with petstore_api.ApiClient() as client:
self.assertIsNotNone(client.pool)
pool_ref = weakref.ref(client._pool)
self.assertIsNotNone(pool_ref())
self.assertIsNone(pool_ref())
def test_atexit_closes_threadpool(self):
client = petstore_api.ApiClient()
self.assertIsNotNone(client.pool)
self.assertIsNotNone(client._pool)
atexit._run_exitfuncs()
self.assertIsNone(client._pool)

View File

@@ -54,15 +54,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -23,15 +23,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() 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:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -36,14 +36,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
try:
try:
# creates an XmlItem
api_instance.create_xml_item(xml_item)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
```
@@ -89,14 +91,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -142,14 +146,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
try:
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -195,14 +201,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 3.4 # float | Input number as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -248,14 +256,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -301,13 +311,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
try:
try:
api_instance.test_body_with_file_schema(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -351,14 +363,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
# Enter a context with an instance of the 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 |
body = petstore_api.User() # User |
try:
try:
api_instance.test_body_with_query_params(query, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -405,15 +419,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -466,9 +482,11 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
@@ -483,10 +501,10 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
try:
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -546,9 +564,11 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
# Enter a context with an instance of the 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'] # list[str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
@@ -557,10 +577,10 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # list[str] | Form parameter enum test (string array) (optional) (default to '$')
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
try:
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -614,19 +634,21 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
required_string_group = 56 # int | Required String in group parameters
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
try:
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -675,14 +697,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = {'key': 'param_example'} # dict(str, str) | request body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
param = {'key': 'param_example'} # dict(str, str) | request body
try:
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(param)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -726,15 +750,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
# Enter a context with an instance of the 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
param2 = 'param2_example' # str | field2
try:
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```
@@ -781,17 +807,19 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
pipe = ['pipe_example'] # list[str] |
# Enter a context with an instance of the 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'] # list[str] |
ioutil = ['ioutil_example'] # list[str] |
http = ['http_example'] # list[str] |
url = ['url_example'] # list[str] |
context = ['context_example'] # list[str] |
try:
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e)
```

View File

@@ -31,15 +31,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test class name in snake case
api_response = api_instance.test_classname(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -35,14 +35,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Add a new pet to the store
api_instance.add_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -93,15 +95,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
try:
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -155,15 +159,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # list[str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # list[str] | Status values that need to be considered for filter
try:
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -216,15 +222,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # list[str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # list[str] | Tags to filter by
try:
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -279,15 +287,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
try:
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -339,14 +349,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Update an existing pet
api_instance.update_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -399,16 +411,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
try:
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -460,17 +474,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = '/path/to/file' # file | file to upload (optional)
try:
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -522,17 +538,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = '/path/to/file' # file | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
try:
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -26,14 +26,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -88,14 +90,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
try:
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -138,15 +142,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# Enter a context with an instance of the 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
try:
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -192,15 +198,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
body = petstore_api.Order() # Order | order placed for purchasing the pet
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
body = petstore_api.Order() # Order | order placed for purchasing the pet
try:
try:
# Place an order for a pet
api_response = api_instance.place_order(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -30,14 +30,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = petstore_api.User() # User | Created user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = petstore_api.User() # User | Created user object
try:
try:
# Create user
api_instance.create_user(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -81,14 +83,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -132,14 +136,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -185,14 +191,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete user
api_instance.delete_user(username)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -237,15 +245,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# Enter a context with an instance of the 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.
try:
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -291,16 +301,18 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
# Enter a context with an instance of the 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
password = 'password_example' # str | The password for login in clear text
try:
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -346,13 +358,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
try:
try:
# Logs out current logged in user session
api_instance.logout_user()
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -395,15 +409,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
# Enter a context with an instance of the 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
body = petstore_api.User() # User | Updated user object
try:
try:
# Updated user
api_instance.update_user(username, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -10,6 +10,7 @@
from __future__ import absolute_import
import atexit
import datetime
from dateutil.parser import parse
import json
@@ -81,11 +82,19 @@ class ApiClient(object):
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
self.client_side_validation = configuration.client_side_validation
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -93,6 +102,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -54,15 +54,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -23,15 +23,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() 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:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -36,14 +36,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body
try:
try:
# creates an XmlItem
api_instance.create_xml_item(xml_item)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->create_xml_item: %s\n" % e)
```
@@ -89,14 +91,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -142,14 +146,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
try:
try:
api_response = api_instance.fake_outer_composite_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -195,14 +201,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 3.4 # float | Input number as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -248,14 +256,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -301,13 +311,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
try:
try:
api_instance.test_body_with_file_schema(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -351,14 +363,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
# Enter a context with an instance of the 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 |
body = petstore_api.User() # User |
try:
try:
api_instance.test_body_with_query_params(query, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -405,15 +419,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test \"client\" model
api_response = api_instance.test_client_model(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -466,9 +482,11 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
@@ -483,10 +501,10 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
try:
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -546,9 +564,11 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
# Enter a context with an instance of the 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'] # list[str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
@@ -557,10 +577,10 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # list[str] | Form parameter enum test (string array) (optional) (default to '$')
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
try:
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -614,19 +634,21 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
required_string_group = 56 # int | Required String in group parameters
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
try:
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -675,14 +697,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = {'key': 'param_example'} # dict(str, str) | request body
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
param = {'key': 'param_example'} # dict(str, str) | request body
try:
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(param)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -726,15 +750,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
# Enter a context with an instance of the 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
param2 = 'param2_example' # str | field2
try:
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```
@@ -781,17 +807,19 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
pipe = ['pipe_example'] # list[str] |
# Enter a context with an instance of the 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'] # list[str] |
ioutil = ['ioutil_example'] # list[str] |
http = ['http_example'] # list[str] |
url = ['url_example'] # list[str] |
context = ['context_example'] # list[str] |
try:
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e)
```

View File

@@ -31,15 +31,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
body = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
body = petstore_api.Client() # Client | client model
try:
try:
# To test class name in snake case
api_response = api_instance.test_classname(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -35,14 +35,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Add a new pet to the store
api_instance.add_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -93,15 +95,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
try:
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -155,15 +159,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # list[str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # list[str] | Status values that need to be considered for filter
try:
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -216,15 +222,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # list[str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # list[str] | Tags to filter by
try:
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -279,15 +287,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
try:
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -339,14 +349,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Update an existing pet
api_instance.update_pet(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -399,16 +411,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
try:
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -460,17 +474,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = '/path/to/file' # file | file to upload (optional)
try:
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -522,17 +538,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = '/path/to/file' # file | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
try:
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -26,14 +26,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -88,14 +90,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
try:
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -138,15 +142,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# Enter a context with an instance of the 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
try:
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -192,15 +198,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
body = petstore_api.Order() # Order | order placed for purchasing the pet
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
body = petstore_api.Order() # Order | order placed for purchasing the pet
try:
try:
# Place an order for a pet
api_response = api_instance.place_order(body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -30,14 +30,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = petstore_api.User() # User | Created user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = petstore_api.User() # User | Created user object
try:
try:
# Create user
api_instance.create_user(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -81,14 +83,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -132,14 +136,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
body = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
body = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -185,14 +191,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete user
api_instance.delete_user(username)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -237,15 +245,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# Enter a context with an instance of the 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.
try:
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -291,16 +301,18 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
# Enter a context with an instance of the 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
password = 'password_example' # str | The password for login in clear text
try:
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -346,13 +358,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
try:
try:
# Logs out current logged in user session
api_instance.logout_user()
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -395,15 +409,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
# Enter a context with an instance of the 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
body = petstore_api.User() # User | Updated user object
try:
try:
# Updated user
api_instance.update_user(username, body)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -10,6 +10,7 @@
from __future__ import absolute_import
import atexit
import datetime
from dateutil.parser import parse
import json
@@ -80,11 +81,19 @@ class ApiClient(object):
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
self.client_side_validation = configuration.client_side_validation
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -92,6 +101,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -11,6 +11,8 @@ $ nosetests -v
import os
import time
import atexit
import weakref
import unittest
from dateutil.parser import parse
@@ -169,3 +171,17 @@ class ApiClientTests(unittest.TestCase):
data = [pet]
result = self.api_client.sanitize_for_serialization(data)
self.assertEqual(result, list_of_pet_dict)
def test_context_manager_closes_threadpool(self):
with petstore_api.ApiClient() as client:
self.assertIsNotNone(client.pool)
pool_ref = weakref.ref(client._pool)
self.assertIsNotNone(pool_ref())
self.assertIsNone(pool_ref())
def test_atexit_closes_threadpool(self):
client = petstore_api.ApiClient()
self.assertIsNotNone(client.pool)
self.assertIsNotNone(client._pool)
atexit._run_exitfuncs()
self.assertIsNone(client._pool)

View File

@@ -53,15 +53,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
client_client = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
client_client = petstore_api.Client() # client.Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(client_client)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -22,16 +22,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
client_client = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
client_client = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(client_client)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -20,14 +20,16 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.DefaultApi()
# 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
api_instance = petstore_api.DefaultApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
api_response = api_instance.foo_get()
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling DefaultApi->foo_get: %s\n" % e)
```

View File

@@ -33,15 +33,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
# 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
api_instance = petstore_api.FakeApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
# Health check endpoint
api_response = api_instance.fake_health_get()
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_health_get: %s\n" % e)
```
@@ -83,16 +85,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = True # bool | Input boolean as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -137,16 +141,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
outer_composite_outer_composite = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
outer_composite_outer_composite = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_composite_serialize(outer_composite_outer_composite=outer_composite_outer_composite)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -191,16 +197,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 3.4 # float | Input number as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = 3.4 # float | Input number as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -245,16 +253,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
body = 'body_example' # str | Input string as post body (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -299,14 +309,16 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
file_schema_test_class_file_schema_test_class = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
# 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
api_instance = petstore_api.FakeApi(api_client)
file_schema_test_class_file_schema_test_class = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass |
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_file_schema(file_schema_test_class_file_schema_test_class)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -349,15 +361,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
user_user = petstore_api.User() # user.User |
# 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
api_instance = petstore_api.FakeApi(api_client)
query = 'query_example' # str |
user_user = petstore_api.User() # user.User |
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_body_with_query_params(query, user_user)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -403,16 +417,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
client_client = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.FakeApi(api_client)
client_client = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test \"client\" model
api_response = api_instance.test_client_model(client_client)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -464,13 +480,15 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 56 # int | None (optional)
float = 3.4 # float | None (optional)
@@ -481,19 +499,19 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -552,9 +570,11 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
@@ -563,12 +583,12 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$'
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg'
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -627,28 +647,30 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
# 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
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -696,15 +718,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
request_body = {'key': 'request_body_example'} # {str: (str,)} | request body
# 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
api_instance = petstore_api.FakeApi(api_client)
request_body = {'key': 'request_body_example'} # {str: (str,)} | request body
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(request_body)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -747,16 +771,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
# 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
api_instance = petstore_api.FakeApi(api_client)
param = 'param_example' # str | field1
param2 = 'param2_example' # str | field2
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```
@@ -802,18 +828,20 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
pipe = ['pipe_example'] # [str] |
ioutil = ['ioutil_example'] # [str] |
http = ['http_example'] # [str] |
url = ['url_example'] # [str] |
context = ['context_example'] # [str] |
# 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
api_instance = petstore_api.FakeApi(api_client)
pipe = ['pipe_example'] # [str] |
ioutil = ['ioutil_example'] # [str] |
http = ['http_example'] # [str] |
url = ['url_example'] # [str] |
context = ['context_example'] # [str] |
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e)
```

View File

@@ -30,16 +30,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
client_client = petstore_api.Client() # client.Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
client_client = petstore_api.Client() # client.Client | client model
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# To test class name in snake case
api_response = api_instance.test_classname(client_client)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -55,15 +55,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Add a new pet to the store
api_instance.add_pet(pet_pet)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -112,24 +114,26 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Deletes a pet
api_instance.delete_pet(pet_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -202,16 +206,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # [str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # [str] | Status values that need to be considered for filter
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -284,16 +290,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # [str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # [str] | Tags to filter by
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -347,16 +355,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -428,15 +438,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
pet_pet = petstore_api.Pet() # pet.Pet | Pet object that needs to be added to the store
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Update an existing pet
api_instance.update_pet(pet_pet)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -487,25 +499,27 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -556,27 +570,29 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# uploads an image
api_response = api_instance.upload_file(pet_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -627,27 +643,29 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = open('/path/to/file', 'rb') # file_type | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -25,15 +25,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# 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
api_instance = petstore_api.StoreApi(api_client)
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -87,15 +89,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -137,16 +141,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# 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
api_instance = petstore_api.StoreApi(api_client)
order_id = 56 # int | ID of pet that needs to be fetched
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -191,16 +197,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_order = petstore_api.Order() # order.Order | order placed for purchasing the pet
# 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
api_instance = petstore_api.StoreApi(api_client)
order_order = petstore_api.Order() # order.Order | order placed for purchasing the pet
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Place an order for a pet
api_response = api_instance.place_order(order_order)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -29,15 +29,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user_user = petstore_api.User() # user.User | Created user object
# 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
api_instance = petstore_api.UserApi(api_client)
user_user = petstore_api.User() # user.User | Created user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Create user
api_instance.create_user(user_user)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -80,15 +82,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user_user = [petstore_api.User()] # [user.User] | List of user object
# 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
api_instance = petstore_api.UserApi(api_client)
user_user = [petstore_api.User()] # [user.User] | List of user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(user_user)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -131,15 +135,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user_user = [petstore_api.User()] # [user.User] | List of user object
# 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
api_instance = petstore_api.UserApi(api_client)
user_user = [petstore_api.User()] # [user.User] | List of user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(user_user)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -184,15 +190,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be deleted
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Delete user
api_instance.delete_user(username)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -236,16 +244,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -290,17 +300,19 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
password = 'password_example' # str | The password for login in clear text
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | The user name for login
password = 'password_example' # str | The password for login in clear text
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -345,14 +357,16 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# 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
api_instance = petstore_api.UserApi(api_client)
# example, this endpoint has no required or optional parameters
try:
# example, this endpoint has no required or optional parameters
try:
# Logs out current logged in user session
api_instance.logout_user()
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -394,16 +408,18 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
user_user = petstore_api.User() # user.User | Updated user object
# 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
api_instance = petstore_api.UserApi(api_client)
username = 'username_example' # str | name that need to be deleted
user_user = petstore_api.User() # user.User | Updated user object
# example passing only required values which don't have defaults set
try:
# example passing only required values which don't have defaults set
try:
# Updated user
api_instance.update_user(username, user_user)
except petstore_api.ApiException as e:
except petstore_api.ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -11,6 +11,7 @@
from __future__ import absolute_import
import json
import atexit
import mimetypes
from multiprocessing.pool import ThreadPool
import os
@@ -79,11 +80,19 @@ class ApiClient(object):
# Set default User-Agent.
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -91,6 +100,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool

View File

@@ -54,15 +54,17 @@ from pprint import pprint
# Defining host is optional and default to http://petstore.swagger.io:80/v2
configuration.host = "http://petstore.swagger.io:80/v2"
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration))
client = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.AnotherFakeApi(api_client)
client = petstore_api.Client() # Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(client)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -23,15 +23,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi()
client = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.AnotherFakeApi(api_client)
client = petstore_api.Client() # Client | client model
try:
try:
# To test special tags
api_response = api_instance.call_123_test_special_tags(client)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
```

View File

@@ -21,13 +21,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.DefaultApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.DefaultApi(api_client)
try:
try:
api_response = api_instance.foo_get()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling DefaultApi->foo_get: %s\n" % e)
```

View File

@@ -34,14 +34,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
try:
try:
# Health check endpoint
api_response = api_instance.fake_health_get()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_health_get: %s\n" % e)
```
@@ -84,14 +86,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = True # bool | Input boolean as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_boolean_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e)
```
@@ -137,14 +141,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
outer_composite = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
# Enter a context with an instance of the 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 = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional)
try:
try:
api_response = api_instance.fake_outer_composite_serialize(outer_composite=outer_composite)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e)
```
@@ -190,14 +196,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 3.4 # float | Input number as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_number_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e)
```
@@ -243,14 +251,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
body = 'body_example' # str | Input string as post body (optional)
# Enter a context with an instance of the 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)
try:
try:
api_response = api_instance.fake_outer_string_serialize(body=body)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e)
```
@@ -296,13 +306,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
file_schema_test_class = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
# Enter a context with an instance of the 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 = petstore_api.FileSchemaTestClass() # FileSchemaTestClass |
try:
try:
api_instance.test_body_with_file_schema(file_schema_test_class)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e)
```
@@ -346,14 +358,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
query = 'query_example' # str |
# Enter a context with an instance of the 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 |
user = petstore_api.User() # User |
try:
try:
api_instance.test_body_with_query_params(query, user)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e)
```
@@ -400,15 +414,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
client = petstore_api.Client() # Client | client model
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
client = petstore_api.Client() # Client | client model
try:
try:
# To test \"client\" model
api_response = api_instance.test_client_model(client)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_client_model: %s\n" % e)
```
@@ -461,9 +477,11 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
number = 3.4 # float | None
# 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
api_instance = petstore_api.FakeApi(api_client)
number = 3.4 # float | None
double = 3.4 # float | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'byte_example' # str | None
@@ -478,10 +496,10 @@ date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)
param_callback = 'param_callback_example' # str | None (optional)
try:
try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e)
```
@@ -541,9 +559,11 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
# Enter a context with an instance of the 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'] # list[str] | Header parameter enum test (string array) (optional)
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
@@ -552,10 +572,10 @@ enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
enum_form_string_array = '$' # list[str] | Form parameter enum test (string array) (optional) (default to '$')
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
try:
try:
# To test enum parameters
api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e)
```
@@ -615,19 +635,21 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
required_string_group = 56 # int | Required String in group parameters
# 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
api_instance = petstore_api.FakeApi(api_client)
required_string_group = 56 # int | Required String in group parameters
required_boolean_group = True # bool | Required Boolean in group parameters
required_int64_group = 56 # int | Required Integer in group parameters
string_group = 56 # int | String in group parameters (optional)
boolean_group = True # bool | Boolean in group parameters (optional)
int64_group = 56 # int | Integer in group parameters (optional)
try:
try:
# Fake endpoint to test group parameters (optional)
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_group_parameters: %s\n" % e)
```
@@ -676,14 +698,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
request_body = {'key': 'request_body_example'} # dict(str, str) | request body
# Enter a context with an instance of the 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'} # dict(str, str) | request body
try:
try:
# test inline additionalProperties
api_instance.test_inline_additional_properties(request_body)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e)
```
@@ -727,15 +751,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
param = 'param_example' # str | field1
# Enter a context with an instance of the 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
param2 = 'param2_example' # str | field2
try:
try:
# test json serialization of form data
api_instance.test_json_form_data(param, param2)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_json_form_data: %s\n" % e)
```
@@ -782,17 +808,19 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.FakeApi()
pipe = ['pipe_example'] # list[str] |
# Enter a context with an instance of the 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'] # list[str] |
ioutil = ['ioutil_example'] # list[str] |
http = ['http_example'] # list[str] |
url = ['url_example'] # list[str] |
context = ['context_example'] # list[str] |
try:
try:
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeApi->test_query_parameter_collection_format: %s\n" % e)
```

View File

@@ -31,15 +31,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration))
client = petstore_api.Client() # Client | client model
# 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
api_instance = petstore_api.FakeClassnameTags123Api(api_client)
client = petstore_api.Client() # Client | client model
try:
try:
# To test class name in snake case
api_response = api_instance.test_classname(client)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e)
```

View File

@@ -35,14 +35,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Add a new pet to the store
api_instance.add_pet(pet)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->add_pet: %s\n" % e)
```
@@ -92,15 +94,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | Pet id to delete
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | Pet id to delete
api_key = 'api_key_example' # str | (optional)
try:
try:
# Deletes a pet
api_instance.delete_pet(pet_id, api_key=api_key)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->delete_pet: %s\n" % e)
```
@@ -153,15 +157,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
status = ['status_example'] # list[str] | Status values that need to be considered for filter
# 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
api_instance = petstore_api.PetApi(api_client)
status = ['status_example'] # list[str] | Status values that need to be considered for filter
try:
try:
# Finds Pets by status
api_response = api_instance.find_pets_by_status(status)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
```
@@ -214,15 +220,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
tags = ['tags_example'] # list[str] | Tags to filter by
# 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
api_instance = petstore_api.PetApi(api_client)
tags = ['tags_example'] # list[str] | Tags to filter by
try:
try:
# Finds Pets by tags
api_response = api_instance.find_pets_by_tags(tags)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
```
@@ -277,15 +285,17 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to return
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to return
try:
try:
# Find pet by ID
api_response = api_instance.get_pet_by_id(pet_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->get_pet_by_id: %s\n" % e)
```
@@ -337,14 +347,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
# 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
api_instance = petstore_api.PetApi(api_client)
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
try:
try:
# Update an existing pet
api_instance.update_pet(pet)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet: %s\n" % e)
```
@@ -396,16 +408,18 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet that needs to be updated
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet that needs to be updated
name = 'name_example' # str | Updated name of the pet (optional)
status = 'status_example' # str | Updated status of the pet (optional)
try:
try:
# Updates a pet in the store with form data
api_instance.update_pet_with_form(pet_id, name=name, status=status)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->update_pet_with_form: %s\n" % e)
```
@@ -457,17 +471,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
file = '/path/to/file' # file | file to upload (optional)
try:
try:
# uploads an image
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
@@ -519,17 +535,19 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
pet_id = 56 # int | ID of pet to update
# 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
api_instance = petstore_api.PetApi(api_client)
pet_id = 56 # int | ID of pet to update
required_file = '/path/to/file' # file | file to upload
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
try:
try:
# uploads an image (required)
api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```

View File

@@ -26,14 +26,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 'order_id_example' # str | ID of the order that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete purchase order by ID
api_instance.delete_order(order_id)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->delete_order: %s\n" % e)
```
@@ -88,14 +90,16 @@ 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"
# Create an instance of the API class
api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration))
# 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
api_instance = petstore_api.StoreApi(api_client)
try:
try:
# Returns pet inventories by status
api_response = api_instance.get_inventory()
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_inventory: %s\n" % e)
```
@@ -138,15 +142,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order_id = 56 # int | ID of pet that needs to be fetched
# Enter a context with an instance of the 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
try:
try:
# Find purchase order by ID
api_response = api_instance.get_order_by_id(order_id)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->get_order_by_id: %s\n" % e)
```
@@ -192,15 +198,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.StoreApi()
order = petstore_api.Order() # Order | order placed for purchasing the pet
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.StoreApi(api_client)
order = petstore_api.Order() # Order | order placed for purchasing the pet
try:
try:
# Place an order for a pet
api_response = api_instance.place_order(order)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling StoreApi->place_order: %s\n" % e)
```

View File

@@ -30,14 +30,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user = petstore_api.User() # User | Created user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user = petstore_api.User() # User | Created user object
try:
try:
# Create user
api_instance.create_user(user)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_user: %s\n" % e)
```
@@ -81,14 +83,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_array_input(user)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e)
```
@@ -132,14 +136,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
user = [petstore_api.User()] # list[User] | List of user object
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
user = [petstore_api.User()] # list[User] | List of user object
try:
try:
# Creates list of users with given input array
api_instance.create_users_with_list_input(user)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e)
```
@@ -185,14 +191,16 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be deleted
# Enter a context with an instance of the 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
try:
try:
# Delete user
api_instance.delete_user(username)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->delete_user: %s\n" % e)
```
@@ -237,15 +245,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing.
# Enter a context with an instance of the 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.
try:
try:
# Get user by user name
api_response = api_instance.get_user_by_name(username)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->get_user_by_name: %s\n" % e)
```
@@ -291,16 +301,18 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | The user name for login
# Enter a context with an instance of the 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
password = 'password_example' # str | The password for login in clear text
try:
try:
# Logs user into the system
api_response = api_instance.login_user(username, password)
pprint(api_response)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->login_user: %s\n" % e)
```
@@ -346,13 +358,15 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
# Enter a context with an instance of the API client
with petstore_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = petstore_api.UserApi(api_client)
try:
try:
# Logs out current logged in user session
api_instance.logout_user()
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->logout_user: %s\n" % e)
```
@@ -395,15 +409,17 @@ import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.UserApi()
username = 'username_example' # str | name that need to be deleted
# Enter a context with an instance of the 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
user = petstore_api.User() # User | Updated user object
try:
try:
# Updated user
api_instance.update_user(username, user)
except ApiException as e:
except ApiException as e:
print("Exception when calling UserApi->update_user: %s\n" % e)
```

View File

@@ -10,6 +10,7 @@
from __future__ import absolute_import
import atexit
import datetime
from dateutil.parser import parse
import json
@@ -80,11 +81,19 @@ class ApiClient(object):
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
self.client_side_validation = configuration.client_side_validation
def __del__(self):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.close()
def close(self):
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
if hasattr(atexit, 'unregister'):
atexit.unregister(self.close)
@property
def pool(self):
@@ -92,6 +101,7 @@ class ApiClient(object):
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
atexit.register(self.close)
self._pool = ThreadPool(self.pool_threads)
return self._pool