Merge remote-tracking branch 'origin/master' into 5.1.x

This commit is contained in:
William Cheng
2021-01-18 11:33:57 +08:00
248 changed files with 4044 additions and 3425 deletions

View File

@@ -88,6 +88,8 @@ Class | Method | HTTP request | Description
*FakeApi* | [**array_of_enums**](docs/FakeApi.md#array_of_enums) | **POST** /fake/refs/array-of-enums | Array of Enums
*FakeApi* | [**boolean**](docs/FakeApi.md#boolean) | **POST** /fake/refs/boolean |
*FakeApi* | [**composed_one_of_number_with_validations**](docs/FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations |
*FakeApi* | [**download_attachment**](docs/FakeApi.md#download_attachment) | **GET** /{fileName} | downloads a file using Content-Disposition
*FakeApi* | [**enum_test**](docs/FakeApi.md#enum_test) | **POST** /fake/refs/enum-test | Object contains enum properties and array properties containing enums
*FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal |
*FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
@@ -103,6 +105,9 @@ Class | Method | HTTP request | Description
*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
*FakeApi* | [**upload_download_file**](docs/FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
*FakeApi* | [**upload_file**](docs/FakeApi.md#upload_file) | **POST** /fake/uploadFile | uploads a file using multipart/form-data
*FakeApi* | [**upload_files**](docs/FakeApi.md#upload_files) | **POST** /fake/uploadFiles | uploads files using multipart/form-data
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
@@ -111,8 +116,6 @@ Class | Method | HTTP request | Description
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
*PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID
@@ -272,7 +275,7 @@ Use specific imports for apis and models like:
- `from petstore_api.api.default_api import DefaultApi`
- `from petstore_api.model.pet import Pet`
Solution 1:
Solution 2:
Before importing the package, adjust the maximum recursion limit as shown below:
```
import sys

View File

@@ -12,6 +12,8 @@ Name | Type | Description | Notes
**string_enum_with_default_value** | [**StringEnumWithDefaultValue**](StringEnumWithDefaultValue.md) | | [optional]
**integer_enum_with_default_value** | [**IntegerEnumWithDefaultValue**](IntegerEnumWithDefaultValue.md) | | [optional]
**integer_enum_one_value** | [**IntegerEnumOneValue**](IntegerEnumOneValue.md) | | [optional]
**inline_array_of_str_enum** | [**[StringEnum]**](StringEnum.md) | | [optional]
**array_of_str_enum** | [**ArrayOfEnums**](ArrayOfEnums.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -9,6 +9,8 @@ Method | HTTP request | Description
[**array_of_enums**](FakeApi.md#array_of_enums) | **POST** /fake/refs/array-of-enums | Array of Enums
[**boolean**](FakeApi.md#boolean) | **POST** /fake/refs/boolean |
[**composed_one_of_number_with_validations**](FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations |
[**download_attachment**](FakeApi.md#download_attachment) | **GET** /{fileName} | downloads a file using Content-Disposition
[**enum_test**](FakeApi.md#enum_test) | **POST** /fake/refs/enum-test | Object contains enum properties and array properties containing enums
[**fake_health_get**](FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint
[**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal |
[**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
@@ -24,6 +26,9 @@ Method | HTTP request | Description
[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
[**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
[**upload_download_file**](FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
[**upload_file**](FakeApi.md#upload_file) | **POST** /fake/uploadFile | uploads a file using multipart/form-data
[**upload_files**](FakeApi.md#upload_files) | **POST** /fake/uploadFiles | uploads files using multipart/form-data
# **additional_properties_with_array_of_enums**
@@ -346,6 +351,144 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **download_attachment**
> file_type download_attachment(file_name)
downloads a file using Content-Disposition
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# 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 = fake_api.FakeApi(api_client)
file_name = "fileName_example" # str | file name
# example passing only required values which don't have defaults set
try:
# downloads a file using Content-Disposition
api_response = api_instance.download_attachment(file_name)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->download_attachment: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file_name** | **str**| file name |
### Return type
**file_type**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | * Content-Disposition - describes the received file. Looks like: &#39;attachment; filename&#x3D;fileName.txt&#39; <br> |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **enum_test**
> EnumTest enum_test()
Object contains enum properties and array properties containing enums
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from petstore_api.model.enum_test import EnumTest
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# 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 = fake_api.FakeApi(api_client)
enum_test = EnumTest(
enum_string="UPPER",
enum_string_required="UPPER",
enum_integer=1,
enum_number=1.1,
string_enum=StringEnum("placed"),
integer_enum=IntegerEnum(0),
string_enum_with_default_value=StringEnumWithDefaultValue("placed"),
integer_enum_with_default_value=IntegerEnumWithDefaultValue(0),
integer_enum_one_value=IntegerEnumOneValue(0),
inline_array_of_str_enum=[
StringEnum("placed"),
],
array_of_str_enum=ArrayOfEnums([
StringEnum("placed"),
]),
) # EnumTest | Input object (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# Object contains enum properties and array properties containing enums
api_response = api_instance.enum_test(enum_test=enum_test)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->enum_test: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_test** | [**EnumTest**](EnumTest.md)| Input object | [optional]
### Return type
[**EnumTest**](EnumTest.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Got object containing enums | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **fake_health_get**
> HealthCheckResult fake_health_get()
@@ -1410,3 +1553,197 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_download_file**
> file_type upload_download_file(body)
uploads a file and downloads a file using application/octet-stream
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# 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 = fake_api.FakeApi(api_client)
body = open('/path/to/file', 'rb') # file_type |
# example passing only required values which don't have defaults set
try:
# uploads a file and downloads a file using application/octet-stream
api_response = api_instance.upload_download_file(body)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->upload_download_file: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **file_type**| |
### Return type
**file_type**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/octet-stream
- **Accept**: application/octet-stream
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_file**
> ApiResponse upload_file(file)
uploads a file using multipart/form-data
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# 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 = fake_api.FakeApi(api_client)
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:
# uploads a file using multipart/form-data
api_response = api_instance.upload_file(file)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->upload_file: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads a file using multipart/form-data
api_response = api_instance.upload_file(file, additional_metadata=additional_metadata)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->upload_file: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file** | **file_type**| file to upload |
**additional_metadata** | **str**| Additional data to pass to server | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_files**
> ApiResponse upload_files()
uploads files using multipart/form-data
### Example
```python
import time
import petstore_api
from petstore_api.api import fake_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# 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 = fake_api.FakeApi(api_client)
files = open('/path/to/file', 'rb') # [file_type] | (optional)
# example passing only required values which don't have defaults set
# and optional values
try:
# uploads files using multipart/form-data
api_response = api_instance.upload_files(files=files)
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->upload_files: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**files** | **[file_type]**| | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@@ -11,8 +11,6 @@ Method | HTTP request | Description
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
# **add_pet**
@@ -823,173 +821,3 @@ void (empty response body)
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_file**
> ApiResponse upload_file(pet_id)
uploads an image
### Example
* OAuth Authentication (petstore_auth):
```python
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# 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 = pet_api.PetApi(api_client)
pet_id = 1 # 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:
# uploads an image
api_response = api_instance.upload_file(pet_id)
pprint(api_response)
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:
# 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:
print("Exception when calling PetApi->upload_file: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **int**| ID of pet to update |
**additional_metadata** | **str**| Additional data to pass to server | [optional]
**file** | **file_type**| file to upload | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_file_with_required_file**
> ApiResponse upload_file_with_required_file(pet_id, required_file)
uploads an image (required)
### Example
* OAuth Authentication (petstore_auth):
```python
import time
import petstore_api
from petstore_api.api import pet_api
from petstore_api.model.api_response import ApiResponse
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: petstore_auth
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# 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 = pet_api.PetApi(api_client)
pet_id = 1 # 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:
# 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:
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:
# 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:
print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **int**| ID of pet to update |
**required_file** | **file_type**| file to upload |
**additional_metadata** | **str**| Additional data to pass to server | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | successful operation | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -102,7 +102,7 @@ class AnotherFakeApi(object):
client
return self.call_with_http_info(**kwargs)
self.call_123_test_special_tags = Endpoint(
self.call_123_test_special_tags = _Endpoint(
settings={
'response_type': (Client,),
'auth': [],

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -96,7 +96,7 @@ class DefaultApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.foo_get = Endpoint(
self.foo_get = _Endpoint(
settings={
'response_type': (InlineResponseDefault,),
'auth': [],

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -23,9 +23,11 @@ from petstore_api.model_utils import ( # noqa: F401
)
from petstore_api.model.additional_properties_with_array_of_enums import AdditionalPropertiesWithArrayOfEnums
from petstore_api.model.animal_farm import AnimalFarm
from petstore_api.model.api_response import ApiResponse
from petstore_api.model.array_of_enums import ArrayOfEnums
from petstore_api.model.client import Client
from petstore_api.model.composed_one_of_number_with_validations import ComposedOneOfNumberWithValidations
from petstore_api.model.enum_test import EnumTest
from petstore_api.model.file_schema_test_class import FileSchemaTestClass
from petstore_api.model.health_check_result import HealthCheckResult
from petstore_api.model.mammal import Mammal
@@ -108,7 +110,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.additional_properties_with_array_of_enums = Endpoint(
self.additional_properties_with_array_of_enums = _Endpoint(
settings={
'response_type': (AdditionalPropertiesWithArrayOfEnums,),
'auth': [],
@@ -220,7 +222,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.array_model = Endpoint(
self.array_model = _Endpoint(
settings={
'response_type': (AnimalFarm,),
'auth': [],
@@ -331,7 +333,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.array_of_enums = Endpoint(
self.array_of_enums = _Endpoint(
settings={
'response_type': (ArrayOfEnums,),
'auth': [],
@@ -443,7 +445,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.boolean = Endpoint(
self.boolean = _Endpoint(
settings={
'response_type': (bool,),
'auth': [],
@@ -555,7 +557,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.composed_one_of_number_with_validations = Endpoint(
self.composed_one_of_number_with_validations = _Endpoint(
settings={
'response_type': (ComposedOneOfNumberWithValidations,),
'auth': [],
@@ -605,6 +607,238 @@ class FakeApi(object):
callable=__composed_one_of_number_with_validations
)
def __download_attachment(
self,
file_name,
**kwargs
):
"""downloads a file using Content-Disposition # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.download_attachment(file_name, async_req=True)
>>> result = thread.get()
Args:
file_name (str): file name
Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
file_type
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['file_name'] = \
file_name
return self.call_with_http_info(**kwargs)
self.download_attachment = _Endpoint(
settings={
'response_type': (file_type,),
'auth': [],
'endpoint_path': '/{fileName}',
'operation_id': 'download_attachment',
'http_method': 'GET',
'servers': [
{
'url': "http://www.jtricks.com",
'description': "No description provided",
},
]
},
params_map={
'all': [
'file_name',
],
'required': [
'file_name',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'file_name':
(str,),
},
'attribute_map': {
'file_name': 'fileName',
},
'location_map': {
'file_name': 'path',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'text/plain'
],
'content_type': [],
},
api_client=api_client,
callable=__download_attachment
)
def __enum_test(
self,
**kwargs
):
"""Object contains enum properties and array properties containing enums # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.enum_test(async_req=True)
>>> result = thread.get()
Keyword Args:
enum_test (EnumTest): Input object. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
EnumTest
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.enum_test = _Endpoint(
settings={
'response_type': (EnumTest,),
'auth': [],
'endpoint_path': '/fake/refs/enum-test',
'operation_id': 'enum_test',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'enum_test',
],
'required': [],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'enum_test':
(EnumTest,),
},
'attribute_map': {
},
'location_map': {
'enum_test': 'body',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'application/json'
]
},
api_client=api_client,
callable=__enum_test
)
def __fake_health_get(
self,
**kwargs
@@ -665,7 +899,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.fake_health_get = Endpoint(
self.fake_health_get = _Endpoint(
settings={
'response_type': (HealthCheckResult,),
'auth': [],
@@ -775,7 +1009,7 @@ class FakeApi(object):
mammal
return self.call_with_http_info(**kwargs)
self.mammal = Endpoint(
self.mammal = _Endpoint(
settings={
'response_type': (Mammal,),
'auth': [],
@@ -889,7 +1123,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.number_with_validations = Endpoint(
self.number_with_validations = _Endpoint(
settings={
'response_type': (NumberWithValidations,),
'auth': [],
@@ -1001,7 +1235,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.object_model_with_ref_props = Endpoint(
self.object_model_with_ref_props = _Endpoint(
settings={
'response_type': (ObjectModelWithRefProps,),
'auth': [],
@@ -1113,7 +1347,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.string = Endpoint(
self.string = _Endpoint(
settings={
'response_type': (str,),
'auth': [],
@@ -1225,7 +1459,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.string_enum = Endpoint(
self.string_enum = _Endpoint(
settings={
'response_type': (StringEnum,),
'auth': [],
@@ -1342,7 +1576,7 @@ class FakeApi(object):
file_schema_test_class
return self.call_with_http_info(**kwargs)
self.test_body_with_file_schema = Endpoint(
self.test_body_with_file_schema = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -1461,7 +1695,7 @@ class FakeApi(object):
user
return self.call_with_http_info(**kwargs)
self.test_body_with_query_params = Endpoint(
self.test_body_with_query_params = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -1583,7 +1817,7 @@ class FakeApi(object):
client
return self.call_with_http_info(**kwargs)
self.test_client_model = Endpoint(
self.test_client_model = _Endpoint(
settings={
'response_type': (Client,),
'auth': [],
@@ -1723,7 +1957,7 @@ class FakeApi(object):
byte
return self.call_with_http_info(**kwargs)
self.test_endpoint_parameters = Endpoint(
self.test_endpoint_parameters = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -1962,7 +2196,7 @@ class FakeApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.test_enum_parameters = Endpoint(
self.test_enum_parameters = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -2177,7 +2411,7 @@ class FakeApi(object):
required_int64_group
return self.call_with_http_info(**kwargs)
self.test_group_parameters = Endpoint(
self.test_group_parameters = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -2320,7 +2554,7 @@ class FakeApi(object):
request_body
return self.call_with_http_info(**kwargs)
self.test_inline_additional_properties = Endpoint(
self.test_inline_additional_properties = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -2439,7 +2673,7 @@ class FakeApi(object):
param2
return self.call_with_http_info(**kwargs)
self.test_json_form_data = Endpoint(
self.test_json_form_data = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -2578,7 +2812,7 @@ class FakeApi(object):
context
return self.call_with_http_info(**kwargs)
self.test_query_parameter_collection_format = Endpoint(
self.test_query_parameter_collection_format = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -2655,3 +2889,357 @@ class FakeApi(object):
api_client=api_client,
callable=__test_query_parameter_collection_format
)
def __upload_download_file(
self,
body,
**kwargs
):
"""uploads a file and downloads a file using application/octet-stream # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_download_file(body, async_req=True)
>>> result = thread.get()
Args:
body (file_type):
Keyword Args:
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
file_type
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['body'] = \
body
return self.call_with_http_info(**kwargs)
self.upload_download_file = _Endpoint(
settings={
'response_type': (file_type,),
'auth': [],
'endpoint_path': '/fake/uploadDownloadFile',
'operation_id': 'upload_download_file',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'body',
],
'required': [
'body',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'body':
(file_type,),
},
'attribute_map': {
},
'location_map': {
'body': 'body',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/octet-stream'
],
'content_type': [
'application/octet-stream'
]
},
api_client=api_client,
callable=__upload_download_file
)
def __upload_file(
self,
file,
**kwargs
):
"""uploads a file using multipart/form-data # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_file(file, async_req=True)
>>> result = thread.get()
Args:
file (file_type): file to upload
Keyword Args:
additional_metadata (str): Additional data to pass to server. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
ApiResponse
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['file'] = \
file
return self.call_with_http_info(**kwargs)
self.upload_file = _Endpoint(
settings={
'response_type': (ApiResponse,),
'auth': [],
'endpoint_path': '/fake/uploadFile',
'operation_id': 'upload_file',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'file',
'additional_metadata',
],
'required': [
'file',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'file':
(file_type,),
'additional_metadata':
(str,),
},
'attribute_map': {
'file': 'file',
'additional_metadata': 'additionalMetadata',
},
'location_map': {
'file': 'form',
'additional_metadata': 'form',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'multipart/form-data'
]
},
api_client=api_client,
callable=__upload_file
)
def __upload_files(
self,
**kwargs
):
"""uploads files using multipart/form-data # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_files(async_req=True)
>>> result = thread.get()
Keyword Args:
files ([file_type]): [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
ApiResponse
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.upload_files = _Endpoint(
settings={
'response_type': (ApiResponse,),
'auth': [],
'endpoint_path': '/fake/uploadFiles',
'operation_id': 'upload_files',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'files',
],
'required': [],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'files':
([file_type],),
},
'attribute_map': {
'files': 'files',
},
'location_map': {
'files': 'form',
},
'collection_format_map': {
'files': 'csv',
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'multipart/form-data'
]
},
api_client=api_client,
callable=__upload_files
)

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -102,7 +102,7 @@ class FakeClassnameTags123Api(object):
client
return self.call_with_http_info(**kwargs)
self.test_classname = Endpoint(
self.test_classname = _Endpoint(
settings={
'response_type': (Client,),
'auth': [

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -21,7 +21,6 @@ from petstore_api.model_utils import ( # noqa: F401
none_type,
validate_and_convert_types
)
from petstore_api.model.api_response import ApiResponse
from petstore_api.model.pet import Pet
@@ -102,7 +101,7 @@ class PetApi(object):
pet
return self.call_with_http_info(**kwargs)
self.add_pet = Endpoint(
self.add_pet = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -231,7 +230,7 @@ class PetApi(object):
pet_id
return self.call_with_http_info(**kwargs)
self.delete_pet = Endpoint(
self.delete_pet = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -353,7 +352,7 @@ class PetApi(object):
status
return self.call_with_http_info(**kwargs)
self.find_pets_by_status = Endpoint(
self.find_pets_by_status = _Endpoint(
settings={
'response_type': ([Pet],),
'auth': [
@@ -482,7 +481,7 @@ class PetApi(object):
tags
return self.call_with_http_info(**kwargs)
self.find_pets_by_tags = Endpoint(
self.find_pets_by_tags = _Endpoint(
settings={
'response_type': ([Pet],),
'auth': [
@@ -604,7 +603,7 @@ class PetApi(object):
pet_id
return self.call_with_http_info(**kwargs)
self.get_pet_by_id = Endpoint(
self.get_pet_by_id = _Endpoint(
settings={
'response_type': (Pet,),
'auth': [
@@ -723,7 +722,7 @@ class PetApi(object):
pet
return self.call_with_http_info(**kwargs)
self.update_pet = Endpoint(
self.update_pet = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -853,7 +852,7 @@ class PetApi(object):
pet_id
return self.call_with_http_info(**kwargs)
self.update_pet_with_form = Endpoint(
self.update_pet_with_form = _Endpoint(
settings={
'response_type': None,
'auth': [
@@ -915,271 +914,3 @@ class PetApi(object):
api_client=api_client,
callable=__update_pet_with_form
)
def __upload_file(
self,
pet_id,
**kwargs
):
"""uploads an image # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_file(pet_id, async_req=True)
>>> result = thread.get()
Args:
pet_id (int): ID of pet to update
Keyword Args:
additional_metadata (str): Additional data to pass to server. [optional]
file (file_type): file to upload. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
ApiResponse
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['pet_id'] = \
pet_id
return self.call_with_http_info(**kwargs)
self.upload_file = Endpoint(
settings={
'response_type': (ApiResponse,),
'auth': [
'petstore_auth'
],
'endpoint_path': '/pet/{petId}/uploadImage',
'operation_id': 'upload_file',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'pet_id',
'additional_metadata',
'file',
],
'required': [
'pet_id',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'pet_id':
(int,),
'additional_metadata':
(str,),
'file':
(file_type,),
},
'attribute_map': {
'pet_id': 'petId',
'additional_metadata': 'additionalMetadata',
'file': 'file',
},
'location_map': {
'pet_id': 'path',
'additional_metadata': 'form',
'file': 'form',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'multipart/form-data'
]
},
api_client=api_client,
callable=__upload_file
)
def __upload_file_with_required_file(
self,
pet_id,
required_file,
**kwargs
):
"""uploads an image (required) # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.upload_file_with_required_file(pet_id, required_file, async_req=True)
>>> result = thread.get()
Args:
pet_id (int): ID of pet to update
required_file (file_type): file to upload
Keyword Args:
additional_metadata (str): Additional data to pass to server. [optional]
_return_http_data_only (bool): response data without head status
code and headers. Default is True.
_preload_content (bool): if False, the urllib3.HTTPResponse object
will be returned without reading/decoding response data.
Default is True.
_request_timeout (float/tuple): timeout setting for this request. If one
number provided, it will be total request timeout. It can also
be a pair (tuple) of (connection, read) timeouts.
Default is None.
_check_input_type (bool): specifies if type checking
should be done one the data sent to the server.
Default is True.
_check_return_type (bool): specifies if type checking
should be done one the data received from the server.
Default is True.
_host_index (int/None): specifies the index of the server
that we want to use.
Default is read from the configuration.
async_req (bool): execute request asynchronously
Returns:
ApiResponse
If the method is called asynchronously, returns the request
thread.
"""
kwargs['async_req'] = kwargs.get(
'async_req', False
)
kwargs['_return_http_data_only'] = kwargs.get(
'_return_http_data_only', True
)
kwargs['_preload_content'] = kwargs.get(
'_preload_content', True
)
kwargs['_request_timeout'] = kwargs.get(
'_request_timeout', None
)
kwargs['_check_input_type'] = kwargs.get(
'_check_input_type', True
)
kwargs['_check_return_type'] = kwargs.get(
'_check_return_type', True
)
kwargs['_host_index'] = kwargs.get('_host_index')
kwargs['pet_id'] = \
pet_id
kwargs['required_file'] = \
required_file
return self.call_with_http_info(**kwargs)
self.upload_file_with_required_file = Endpoint(
settings={
'response_type': (ApiResponse,),
'auth': [
'petstore_auth'
],
'endpoint_path': '/fake/{petId}/uploadImageWithRequiredFile',
'operation_id': 'upload_file_with_required_file',
'http_method': 'POST',
'servers': None,
},
params_map={
'all': [
'pet_id',
'required_file',
'additional_metadata',
],
'required': [
'pet_id',
'required_file',
],
'nullable': [
],
'enum': [
],
'validation': [
]
},
root_map={
'validations': {
},
'allowed_values': {
},
'openapi_types': {
'pet_id':
(int,),
'required_file':
(file_type,),
'additional_metadata':
(str,),
},
'attribute_map': {
'pet_id': 'petId',
'required_file': 'requiredFile',
'additional_metadata': 'additionalMetadata',
},
'location_map': {
'pet_id': 'path',
'required_file': 'form',
'additional_metadata': 'form',
},
'collection_format_map': {
}
},
headers_map={
'accept': [
'application/json'
],
'content_type': [
'multipart/form-data'
]
},
api_client=api_client,
callable=__upload_file_with_required_file
)

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -102,7 +102,7 @@ class StoreApi(object):
order_id
return self.call_with_http_info(**kwargs)
self.delete_order = Endpoint(
self.delete_order = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -212,7 +212,7 @@ class StoreApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.get_inventory = Endpoint(
self.get_inventory = _Endpoint(
settings={
'response_type': ({str: (int,)},),
'auth': [
@@ -324,7 +324,7 @@ class StoreApi(object):
order_id
return self.call_with_http_info(**kwargs)
self.get_order_by_id = Endpoint(
self.get_order_by_id = _Endpoint(
settings={
'response_type': (Order,),
'auth': [],
@@ -447,7 +447,7 @@ class StoreApi(object):
order
return self.call_with_http_info(**kwargs)
self.place_order = Endpoint(
self.place_order = _Endpoint(
settings={
'response_type': (Order,),
'auth': [],

View File

@@ -11,7 +11,7 @@
import re # noqa: F401
import sys # noqa: F401
from petstore_api.api_client import ApiClient, Endpoint
from petstore_api.api_client import ApiClient, Endpoint as _Endpoint
from petstore_api.model_utils import ( # noqa: F401
check_allowed_values,
check_validations,
@@ -102,7 +102,7 @@ class UserApi(object):
user
return self.call_with_http_info(**kwargs)
self.create_user = Endpoint(
self.create_user = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -217,7 +217,7 @@ class UserApi(object):
user
return self.call_with_http_info(**kwargs)
self.create_users_with_array_input = Endpoint(
self.create_users_with_array_input = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -332,7 +332,7 @@ class UserApi(object):
user
return self.call_with_http_info(**kwargs)
self.create_users_with_list_input = Endpoint(
self.create_users_with_list_input = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -448,7 +448,7 @@ class UserApi(object):
username
return self.call_with_http_info(**kwargs)
self.delete_user = Endpoint(
self.delete_user = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -562,7 +562,7 @@ class UserApi(object):
username
return self.call_with_http_info(**kwargs)
self.get_user_by_name = Endpoint(
self.get_user_by_name = _Endpoint(
settings={
'response_type': (User,),
'auth': [],
@@ -683,7 +683,7 @@ class UserApi(object):
password
return self.call_with_http_info(**kwargs)
self.login_user = Endpoint(
self.login_user = _Endpoint(
settings={
'response_type': (str,),
'auth': [],
@@ -801,7 +801,7 @@ class UserApi(object):
kwargs['_host_index'] = kwargs.get('_host_index')
return self.call_with_http_info(**kwargs)
self.logout_user = Endpoint(
self.logout_user = _Endpoint(
settings={
'response_type': None,
'auth': [],
@@ -913,7 +913,7 @@ class UserApi(object):
user
return self.call_with_http_info(**kwargs)
self.update_user = Endpoint(
self.update_user = _Endpoint(
settings={
'response_type': None,
'auth': [],

View File

@@ -201,8 +201,6 @@ class ApiClient(object):
e.body = e.body.decode('utf-8')
raise e
content_type = response_data.getheader('content-type')
self.last_response = response_data
return_data = response_data
@@ -211,15 +209,17 @@ class ApiClient(object):
return (return_data)
return return_data
if response_type not in ["file", "bytes"]:
match = None
if content_type is not None:
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
encoding = match.group(1) if match else "utf-8"
response_data.data = response_data.data.decode(encoding)
# deserialize response data
if response_type:
if response_type != (file_type,):
encoding = "utf-8"
content_type = response_data.getheader('content-type')
if content_type is not None:
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type)
if match:
encoding = match.group(1)
response_data.data = response_data.data.decode(encoding)
return_data = self.deserialize(
response_data,
response_type,
@@ -256,7 +256,7 @@ class ApiClient(object):
@classmethod
def sanitize_for_serialization(cls, obj):
"""Builds a JSON POST object.
"""Prepares data for transmission before it is sent with the rest client
If obj is None, return None.
If obj is str, int, long, float, bool, return directly.
If obj is datetime.datetime, datetime.date
@@ -264,6 +264,7 @@ class ApiClient(object):
If obj is list, sanitize each element in the list.
If obj is dict, return the dict.
If obj is OpenAPI model, return the properties dict.
If obj is io.IOBase, return the bytes
:param obj: The data to serialize.
:return: The serialized form of data.
"""
@@ -271,6 +272,8 @@ class ApiClient(object):
return {
key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items()
}
elif isinstance(obj, io.IOBase):
return cls.get_file_data_and_close_file(obj)
elif isinstance(obj, (str, int, float, none_type, bool)):
return obj
elif isinstance(obj, (datetime, date)):
@@ -514,6 +517,12 @@ class ApiClient(object):
new_params.append((k, v))
return new_params
@staticmethod
def get_file_data_and_close_file(file_instance: io.IOBase) -> bytes:
file_data = file_instance.read()
file_instance.close()
return file_data
def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None):
"""Builds form parameters.
@@ -539,12 +548,11 @@ class ApiClient(object):
"for %s must be open." % param_name
)
filename = os.path.basename(file_instance.name)
filedata = file_instance.read()
filedata = self.get_file_data_and_close_file(file_instance)
mimetype = (mimetypes.guess_type(filename)[0] or
'application/octet-stream')
params.append(
tuple([param_name, tuple([filename, filedata, mimetype])]))
file_instance.close()
return params

View File

@@ -29,11 +29,13 @@ from petstore_api.model_utils import ( # noqa: F401
)
def lazy_import():
from petstore_api.model.array_of_enums import ArrayOfEnums
from petstore_api.model.integer_enum import IntegerEnum
from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue
from petstore_api.model.integer_enum_with_default_value import IntegerEnumWithDefaultValue
from petstore_api.model.string_enum import StringEnum
from petstore_api.model.string_enum_with_default_value import StringEnumWithDefaultValue
globals()['ArrayOfEnums'] = ArrayOfEnums
globals()['IntegerEnum'] = IntegerEnum
globals()['IntegerEnumOneValue'] = IntegerEnumOneValue
globals()['IntegerEnumWithDefaultValue'] = IntegerEnumWithDefaultValue
@@ -114,6 +116,8 @@ class EnumTest(ModelNormal):
'string_enum_with_default_value': (StringEnumWithDefaultValue,), # noqa: E501
'integer_enum_with_default_value': (IntegerEnumWithDefaultValue,), # noqa: E501
'integer_enum_one_value': (IntegerEnumOneValue,), # noqa: E501
'inline_array_of_str_enum': ([StringEnum],), # noqa: E501
'array_of_str_enum': (ArrayOfEnums,), # noqa: E501
}
@cached_property
@@ -131,6 +135,8 @@ class EnumTest(ModelNormal):
'string_enum_with_default_value': 'StringEnumWithDefaultValue', # noqa: E501
'integer_enum_with_default_value': 'IntegerEnumWithDefaultValue', # noqa: E501
'integer_enum_one_value': 'IntegerEnumOneValue', # noqa: E501
'inline_array_of_str_enum': 'InlineArrayOfStrEnum', # noqa: E501
'array_of_str_enum': 'ArrayOfStrEnum', # noqa: E501
}
_composed_schemas = {}
@@ -190,6 +196,8 @@ class EnumTest(ModelNormal):
string_enum_with_default_value (StringEnumWithDefaultValue): [optional] # noqa: E501
integer_enum_with_default_value (IntegerEnumWithDefaultValue): [optional] # noqa: E501
integer_enum_one_value (IntegerEnumOneValue): [optional] # noqa: E501
inline_array_of_str_enum ([StringEnum]): [optional] # noqa: E501
array_of_str_enum (ArrayOfEnums): [optional] # noqa: E501
"""
_check_type = kwargs.pop('_check_type', True)

View File

@@ -1493,10 +1493,13 @@ def model_to_dict(model_instance, serialize=True):
# exist in attribute_map
attr = model_instance.attribute_map.get(attr, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: model_to_dict(x, serialize=serialize)
if hasattr(x, '_data_store') else x, value
))
if not value or isinstance(value[0], PRIMITIVE_TYPES):
# empty list or primitive types
result[attr] = value
elif isinstance(value[0], ModelSimple):
result[attr] = [x.value for x in value]
else:
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0],

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 B

View File

@@ -0,0 +1,46 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import sys
import unittest
import petstore_api
from petstore_api.model.enum_test import EnumTest
from petstore_api.model.string_enum import StringEnum
from petstore_api.model.array_of_enums import ArrayOfEnums
class TestEnumTest(unittest.TestCase):
"""EnumTest unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testEnumTest(self):
"""Test EnumTest"""
# inline array of enums
model = EnumTest(
enum_string_required='lower',
inline_array_of_str_enum=[StringEnum('approved')]
)
# refed array of enums
model = EnumTest(
enum_string_required='lower',
array_of_str_enum=ArrayOfEnums([StringEnum('approved')])
)
if __name__ == '__main__':
unittest.main()

View File

@@ -11,13 +11,15 @@
import sys
from collections import namedtuple
import unittest
import os
import json
import unittest
from unittest.mock import patch
import petstore_api
from petstore_api.api.fake_api import FakeApi # noqa: E501
from petstore_api.rest import RESTClientObject, RESTResponse
from petstore_api.model_utils import file_type
HTTPResponse = namedtuple(
'urllib3_response_HTTPResponse',
@@ -52,22 +54,35 @@ class TestFakeApi(unittest.TestCase):
return RESTResponse(http_response)
@staticmethod
def assert_request_called_with(mock_method, url, value):
mock_method.assert_called_with(
'POST',
url,
def assert_request_called_with(
mock_method,
url,
accept='application/json',
http_method='POST',
**kwargs
):
headers = {
'Accept': accept,
'User-Agent': 'OpenAPI-Generator/1.0.0/python',
}
if 'content_type' in kwargs:
headers['Content-Type'] = kwargs['content_type']
used_kwargs = dict(
_preload_content=True,
_request_timeout=None,
body=value,
headers={
'Accept': 'application/json',
'User-Agent': 'OpenAPI-Generator/1.0.0/python',
'Content-Type': 'application/json'
},
post_params=[],
headers=headers,
query_params=[]
)
if 'post_params' in kwargs:
used_kwargs['post_params'] = kwargs['post_params']
if 'body' in kwargs:
used_kwargs['body'] = kwargs['body']
else:
mock_method.assert_called_with(
http_method,
url,
**used_kwargs
)
def test_array_model(self):
"""Test case for array_model
@@ -86,7 +101,7 @@ class TestFakeApi(unittest.TestCase):
mock_method.return_value = self.mock_response(json_data)
response = endpoint(body=body)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/arraymodel', json_data)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/arraymodel', body=json_data)
assert isinstance(response, animal_farm.AnimalFarm)
assert response == body
@@ -119,6 +134,52 @@ class TestFakeApi(unittest.TestCase):
"""
pass
def test_enum_test(self):
"""Test case for enum_test
Object contains enum properties and array properties containing enums
"""
from petstore_api.model.enum_test import EnumTest
from petstore_api.model.string_enum import StringEnum
from petstore_api.model.array_of_enums import ArrayOfEnums
endpoint = self.api.enum_test
assert endpoint.openapi_types['enum_test'] == (EnumTest,)
assert endpoint.settings['response_type'] == (EnumTest,)
# serialization + deserialization works w/ inline array
with patch.object(RESTClientObject, 'request') as mock_method:
body = EnumTest(
enum_string_required='lower',
inline_array_of_str_enum=[StringEnum('approved')]
)
json_value = {'enum_string_required': 'lower', 'InlineArrayOfStrEnum': ['approved']}
mock_method.return_value = self.mock_response(json_value)
response = endpoint(enum_test=body)
self.assert_request_called_with(
mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum-test', body=json_value)
assert isinstance(response, EnumTest)
assert response == body
# serialization + deserialization works w/ refed array
with patch.object(RESTClientObject, 'request') as mock_method:
body = EnumTest(
enum_string_required='lower',
array_of_str_enum=ArrayOfEnums([StringEnum('approved')])
)
json_value = {'enum_string_required': 'lower', 'ArrayOfStrEnum': ['approved']}
mock_method.return_value = self.mock_response(json_value)
response = endpoint(enum_test=body)
self.assert_request_called_with(
mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum-test', body=json_value)
assert isinstance(response, EnumTest)
assert response == body
def test_array_of_enums(self):
"""Test case for array_of_enums
@@ -137,7 +198,7 @@ class TestFakeApi(unittest.TestCase):
mock_method.return_value = self.mock_response(value_simple)
response = endpoint(array_of_enums=body)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/array-of-enums', value_simple)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/array-of-enums', body=value_simple)
assert isinstance(response, array_of_enums.ArrayOfEnums)
assert response.value == value
@@ -158,7 +219,7 @@ class TestFakeApi(unittest.TestCase):
mock_method.return_value = self.mock_response(value)
response = endpoint(body=body)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/number', value)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/number', body=value)
assert isinstance(response, number_with_validations.NumberWithValidations)
assert response.value == value
@@ -201,7 +262,7 @@ class TestFakeApi(unittest.TestCase):
self.assert_request_called_with(
mock_method,
'http://petstore.swagger.io:80/v2/fake/refs/object_model_with_ref_props',
json_payload
body=json_payload
)
assert isinstance(response, expected_model.__class__)
@@ -239,7 +300,7 @@ class TestFakeApi(unittest.TestCase):
self.assert_request_called_with(
mock_method,
'http://petstore.swagger.io:80/v2/fake/refs/composed_one_of_number_with_validations',
value_simple
body=value_simple
)
assert isinstance(response, body.__class__)
@@ -260,7 +321,7 @@ class TestFakeApi(unittest.TestCase):
mock_method.return_value = self.mock_response(value_simple)
response = endpoint(body=body)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/string', value_simple)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/string', body=value_simple)
assert isinstance(response, str)
assert response == value_simple
@@ -282,11 +343,207 @@ class TestFakeApi(unittest.TestCase):
mock_method.return_value = self.mock_response(value)
response = endpoint(body=body)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', value)
self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', body=value)
assert isinstance(response, string_enum.StringEnum)
assert response.value == value
def test_upload_file(self):
# uploads a file
test_file_dir = os.path.realpath(
os.path.join(os.path.dirname(__file__), "..", "testfiles"))
file_path1 = os.path.join(test_file_dir, "1px_pic1.png")
headers = {}
def get_headers():
return headers
def get_header(name, default=None):
return headers.get(name, default)
api_respponse = {
'code': 200,
'type': 'blah',
'message': 'file upload succeeded'
}
http_response = HTTPResponse(
status=200,
reason='OK',
data=json.dumps(api_respponse).encode('utf-8'),
getheaders=get_headers,
getheader=get_header
)
mock_response = RESTResponse(http_response)
file1 = open(file_path1, "rb")
try:
with patch.object(RESTClientObject, 'request') as mock_method:
mock_method.return_value = mock_response
res = self.api.upload_file(
file=file1)
body = None
post_params=[
('file', ('1px_pic1.png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82', 'image/png')),
]
self.assert_request_called_with(
mock_method,
'http://petstore.swagger.io:80/v2/fake/uploadFile',
body=body, post_params=post_params, content_type='multipart/form-data'
)
except petstore_api.ApiException as e:
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
finally:
file1.close()
# passing in an array of files to when file only allows one
# raises an exceptions
try:
file = open(file_path1, "rb")
with self.assertRaises(petstore_api.ApiTypeError) as exc:
self.api.upload_file(file=[file])
finally:
file.close()
# passing in a closed file raises an exception
with self.assertRaises(petstore_api.ApiValueError) as exc:
file = open(file_path1, "rb")
file.close()
self.api.upload_file(file=file)
def test_upload_files(self):
test_file_dir = os.path.realpath(
os.path.join(os.path.dirname(__file__), "..", "testfiles"))
file_path1 = os.path.join(test_file_dir, "1px_pic1.png")
file_path2 = os.path.join(test_file_dir, "1px_pic2.png")
headers = {}
def get_headers():
return headers
def get_header(name, default=None):
return headers.get(name, default)
api_respponse = {
'code': 200,
'type': 'blah',
'message': 'file upload succeeded'
}
http_response = HTTPResponse(
status=200,
reason='OK',
data=json.dumps(api_respponse).encode('utf-8'),
getheaders=get_headers,
getheader=get_header
)
mock_response = RESTResponse(http_response)
file1 = open(file_path1, "rb")
file2 = open(file_path2, "rb")
try:
with patch.object(RESTClientObject, 'request') as mock_method:
mock_method.return_value = mock_response
res = self.api.upload_files(
files=[file1, file2])
post_params=[
('files', ('1px_pic1.png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82', 'image/png')),
('files', ('1px_pic2.png', b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x00\x00\x00\x00:~\x9bU\x00\x00\x00\nIDATx\x9cc\xfa\x0f\x00\x01\x05\x01\x02\xcf\xa0.\xcd\x00\x00\x00\x00IEND\xaeB`\x82', 'image/png'))
]
self.assert_request_called_with(
mock_method,
'http://petstore.swagger.io:80/v2/fake/uploadFiles',
body=None, post_params=post_params, content_type='multipart/form-data'
)
except petstore_api.ApiException as e:
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
finally:
file1.close()
file2.close()
# passing in a single file when an array of file is required
# raises an exception
try:
file = open(file_path1, "rb")
with self.assertRaises(petstore_api.ApiTypeError) as exc:
self.api.upload_files(files=file)
finally:
file.close()
def test_download_attachment(self):
"""Ensures that file deserialization works"""
# sample from http://www.jtricks.com/download-text
file_name = 'content.txt'
headers = {'Content-Disposition': 'attachment; filename={}'.format(file_name), 'Content-Type': 'text/plain'}
def get_headers():
return headers
def get_header(name, default=None):
return headers.get(name, default)
file_data = (
"You are reading text file that was supposed to be downloaded\r\n"
"to your hard disk. If your browser offered to save you the file,"
"\r\nthen it handled the Content-Disposition header correctly."
)
http_response = HTTPResponse(
status=200,
reason='OK',
data=file_data,
getheaders=get_headers,
getheader=get_header
)
# deserialize response to a file
mock_response = RESTResponse(http_response)
with patch.object(RESTClientObject, 'request') as mock_method:
mock_method.return_value = mock_response
try:
file_object = self.api.download_attachment(file_name='download-text')
self.assert_request_called_with(
mock_method,
'http://www.jtricks.com/download-text',
http_method='GET',
accept='text/plain',
)
self.assertTrue(isinstance(file_object, file_type))
self.assertFalse(file_object.closed)
self.assertEqual(file_object.read(), file_data.encode('utf-8'))
finally:
file_object.close()
os.unlink(file_object.name)
def test_upload_download_file(self):
test_file_dir = os.path.realpath(
os.path.join(os.path.dirname(__file__), "..", "testfiles"))
file_path1 = os.path.join(test_file_dir, "1px_pic1.png")
with open(file_path1, "rb") as f:
expected_file_data = f.read()
headers = {'Content-Type': 'application/octet-stream'}
def get_headers():
return headers
def get_header(name, default=None):
return headers.get(name, default)
http_response = HTTPResponse(
status=200,
reason='OK',
data=expected_file_data,
getheaders=get_headers,
getheader=get_header
)
mock_response = RESTResponse(http_response)
file1 = open(file_path1, "rb")
try:
with patch.object(RESTClientObject, 'request') as mock_method:
mock_method.return_value = mock_response
downloaded_file = self.api.upload_download_file(body=file1)
self.assert_request_called_with(
mock_method,
'http://petstore.swagger.io:80/v2/fake/uploadDownloadFile',
body=expected_file_data, content_type='application/octet-stream'
)
self.assertTrue(isinstance(downloaded_file, file_type))
self.assertFalse(downloaded_file.closed)
self.assertEqual(downloaded_file.read(), expected_file_data)
except petstore_api.ApiException as e:
self.fail("upload_download_file() raised {0} unexpectedly".format(type(e)))
finally:
file1.close()
downloaded_file.close()
os.unlink(downloaded_file.name)
def test_test_body_with_file_schema(self):
"""Test case for test_body_with_file_schema