[Python] Add test object serialization for multipart requests (#18156)

* [Python] add test object serialization for multipart requests #18140

* [python] update samples

* [python] update samples
This commit is contained in:
ふぁ
2024-03-24 10:37:44 +09:00
committed by GitHub
parent e17777044e
commit 9acd620bbb
38 changed files with 1779 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ docs/TaskActivity.md
docs/TestErrorResponsesWithModel400Response.md
docs/TestErrorResponsesWithModel404Response.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/TestObjectForMultipartRequestsRequestMarker.md
docs/Tiger.md
docs/UnnamedDictWithAdditionalModelListProperties.md
docs/UnnamedDictWithAdditionalStringListProperties.md
@@ -206,6 +207,7 @@ petstore_api/models/task_activity.py
petstore_api/models/test_error_responses_with_model400_response.py
petstore_api/models/test_error_responses_with_model404_response.py
petstore_api/models/test_inline_freeform_additional_properties_request.py
petstore_api/models/test_object_for_multipart_requests_request_marker.py
petstore_api/models/tiger.py
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
petstore_api/models/unnamed_dict_with_additional_string_list_properties.py

View File

@@ -121,6 +121,7 @@ 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_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties
*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests |
*FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters |
*FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
@@ -237,6 +238,7 @@ Class | Method | HTTP request | Description
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
- [Tiger](docs/Tiger.md)
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
- [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md)

View File

@@ -37,6 +37,7 @@ Method | HTTP request | Description
[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
[**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
[**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests |
[**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters |
[**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map
@@ -2241,6 +2242,68 @@ 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)
# **test_object_for_multipart_requests**
> test_object_for_multipart_requests(marker)
### Example
```python
import time
import os
import petstore_api
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.rest import ApiException
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
async with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
marker = petstore_api.TestObjectForMultipartRequestsRequestMarker() # TestObjectForMultipartRequestsRequestMarker |
try:
await api_instance.test_object_for_multipart_requests(marker)
except Exception as e:
print("Exception when calling FakeApi->test_object_for_multipart_requests: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**marker** | [**TestObjectForMultipartRequestsRequestMarker**](TestObjectForMultipartRequestsRequestMarker.md)| |
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: Not defined
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Success | - |
[[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)
# **test_query_parameter_collection_format**
> test_query_parameter_collection_format(pipe, ioutil, http, url, context, allow_empty, language=language)

View File

@@ -0,0 +1,28 @@
# TestObjectForMultipartRequestsRequestMarker
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
# TODO update the JSON string below
json = "{}"
# create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string
test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.from_json(json)
# print the JSON string representation of the object
print TestObjectForMultipartRequestsRequestMarker.to_json()
# convert the object into a dict
test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.to_dict()
# create an instance of TestObjectForMultipartRequestsRequestMarker from a dict
test_object_for_multipart_requests_request_marker_form_dict = test_object_for_multipart_requests_request_marker.from_dict(test_object_for_multipart_requests_request_marker_dict)
```
[[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

@@ -126,6 +126,7 @@ from petstore_api.models.task_activity import TaskActivity
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties

View File

@@ -35,6 +35,7 @@ from petstore_api.models.outer_object_with_enum_property import OuterObjectWithE
from petstore_api.models.pet import Pet
from petstore_api.models.tag import Tag
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.models.user import User
from petstore_api.api_client import ApiClient
@@ -4233,6 +4234,129 @@ class FakeApi:
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))
@validate_arguments
async def test_object_for_multipart_requests(self, marker : TestObjectForMultipartRequestsRequestMarker, **kwargs) -> None: # noqa: E501
"""test_object_for_multipart_requests # noqa: E501
:param marker: (required)
:type marker: TestObjectForMultipartRequestsRequestMarker
:param _request_timeout: 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.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: None
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
message = "Error! Please call the test_object_for_multipart_requests_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
raise ValueError(message)
return await self.test_object_for_multipart_requests_with_http_info(marker, **kwargs) # noqa: E501
@validate_arguments
async def test_object_for_multipart_requests_with_http_info(self, marker : TestObjectForMultipartRequestsRequestMarker, **kwargs) -> ApiResponse: # noqa: E501
"""test_object_for_multipart_requests # noqa: E501
:param marker: (required)
:type marker: TestObjectForMultipartRequestsRequestMarker
:param _preload_content: if False, the ApiResponse.data will
be set to none and raw_data will store the
HTTP response body without reading/decoding.
Default is True.
:type _preload_content: bool, optional
:param _return_http_data_only: response data instead of ApiResponse
object with status code, headers, etc
:type _return_http_data_only: bool, optional
:param _request_timeout: 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.
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auth: dict, optional
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: None
"""
_params = locals()
_all_params = [
'marker'
]
_all_params.extend(
[
'_return_http_data_only',
'_preload_content',
'_request_timeout',
'_request_auth',
'_content_type',
'_headers'
]
)
# validate the arguments
for _key, _val in _params['kwargs'].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method test_object_for_multipart_requests" % _key
)
_params[_key] = _val
del _params['kwargs']
_collection_formats = {}
# process the path parameters
_path_params = {}
# process the query parameters
_query_params = []
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
# process the form parameters
_form_params = []
_files = {}
if _params['marker'] is not None:
_form_params.append(('marker', _params['marker']))
# process the body parameter
_body_params = None
# set the HTTP header `Content-Type`
_content_types_list = _params.get('_content_type',
self.api_client.select_header_content_type(
['multipart/form-data']))
if _content_types_list:
_header_params['Content-Type'] = _content_types_list
# authentication setting
_auth_settings = [] # noqa: E501
_response_types_map = {}
return await self.api_client.call_api(
'/fake/object_for_multipart_requests', 'POST',
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
_return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
_preload_content=_params.get('_preload_content', True),
_request_timeout=_params.get('_request_timeout'),
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))
@validate_arguments
async def test_query_parameter_collection_format(self, pipe : conlist(StrictStr), ioutil : conlist(StrictStr), http : conlist(StrictStr), url : conlist(StrictStr), context : conlist(StrictStr), allow_empty : StrictStr, language : Optional[Dict[str, StrictStr]] = None, **kwargs) -> None: # noqa: E501
"""test_query_parameter_collection_format # noqa: E501

View File

@@ -101,6 +101,7 @@ from petstore_api.models.task_activity import TaskActivity
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties

View File

@@ -0,0 +1,71 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictStr
class TestObjectForMultipartRequestsRequestMarker(BaseModel):
"""
TestObjectForMultipartRequestsRequestMarker
"""
name: Optional[StrictStr] = None
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> TestObjectForMultipartRequestsRequestMarker:
"""Create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> TestObjectForMultipartRequestsRequestMarker:
"""Create an instance of TestObjectForMultipartRequestsRequestMarker from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return TestObjectForMultipartRequestsRequestMarker.parse_obj(obj)
_obj = TestObjectForMultipartRequestsRequestMarker.parse_obj({
"name": obj.get("name")
})
return _obj

View File

@@ -0,0 +1,52 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
import datetime
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker # noqa: E501
class TestTestObjectForMultipartRequestsRequestMarker(unittest.TestCase):
"""TestObjectForMultipartRequestsRequestMarker unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> TestObjectForMultipartRequestsRequestMarker:
"""Test TestObjectForMultipartRequestsRequestMarker
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `TestObjectForMultipartRequestsRequestMarker`
"""
model = TestObjectForMultipartRequestsRequestMarker() # noqa: E501
if include_optional:
return TestObjectForMultipartRequestsRequestMarker(
name = ''
)
else:
return TestObjectForMultipartRequestsRequestMarker(
)
"""
def testTestObjectForMultipartRequestsRequestMarker(self):
"""Test TestObjectForMultipartRequestsRequestMarker"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()