diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 06148fef489..e26a5ac3112 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -88,7 +88,7 @@ class ApiClient(object): _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None): - config = Configuration() + config = self.configuration # header parameters header_params = header_params or {} diff --git a/samples/client/petstore/python/.swagger-codegen/VERSION b/samples/client/petstore/python/.swagger-codegen/VERSION index 7fea99011a6..f9f7450d135 100644 --- a/samples/client/petstore/python/.swagger-codegen/VERSION +++ b/samples/client/petstore/python/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 2e655169b7f..2395497d682 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -75,6 +75,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of 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 diff --git a/samples/client/petstore/python/docs/FakeApi.md b/samples/client/petstore/python/docs/FakeApi.md index e8bbda38d65..eb669540e53 100644 --- a/samples/client/petstore/python/docs/FakeApi.md +++ b/samples/client/petstore/python/docs/FakeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data # **fake_outer_boolean_serialize** @@ -274,7 +275,7 @@ api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration)) number = 3.4 # float | None double = 1.2 # float | None pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None -byte = 'B' # str | None +byte = 'byte_example' # str | None integer = 56 # int | None (optional) int32 = 56 # int | None (optional) int64 = 789 # int | None (optional) @@ -388,3 +389,52 @@ 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_json_form_data** +> test_json_form_data(param, param2) + +test json serialization of form data + + + +### Example +```python +from __future__ import print_function +import time +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 +param2 = 'param2_example' # str | field2 + +try: + # test json serialization of form data + api_instance.test_json_form_data(param, param2) +except ApiException as e: + print("Exception when calling FakeApi->test_json_form_data: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **str**| field1 | + **param2** | **str**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[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) + diff --git a/samples/client/petstore/python/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python/docs/FakeClassnameTags123Api.md index 166ee467c4f..de281a3b29a 100644 --- a/samples/client/petstore/python/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python/docs/FakeClassnameTags123Api.md @@ -14,7 +14,7 @@ To test class name in snake case ### Example ```python -from __future__ import print_statement +from __future__ import print_function import time import petstore_api from petstore_api.rest import ApiException diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 40b24273191..c0f44856996 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -97,7 +97,7 @@ class ApiClient(object): _return_http_data_only=None, collection_formats=None, _preload_content=True, _request_timeout=None): - config = Configuration() + config = self.configuration # header parameters header_params = header_params or {} diff --git a/samples/client/petstore/python/petstore_api/apis/fake_api.py b/samples/client/petstore/python/petstore_api/apis/fake_api.py index 628ed03c05a..46fb22f7290 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_api.py @@ -39,22 +39,18 @@ class FakeApi(object): """ Test serialization of outer boolean types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_boolean_serialize(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_boolean_serialize(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterBoolean body: Input boolean as post body :return: OuterBoolean If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): + if kwargs.get('async'): return self.fake_outer_boolean_serialize_with_http_info(**kwargs) else: (data) = self.fake_outer_boolean_serialize_with_http_info(**kwargs) @@ -64,15 +60,11 @@ class FakeApi(object): """ Test serialization of outer boolean types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_boolean_serialize_with_http_info(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_boolean_serialize_with_http_info(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterBoolean body: Input boolean as post body :return: OuterBoolean If the method is called asynchronously, @@ -80,7 +72,7 @@ class FakeApi(object): """ all_params = ['body'] - all_params.append('callback') + all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') @@ -122,7 +114,7 @@ class FakeApi(object): files=local_var_files, response_type='OuterBoolean', auth_settings=auth_settings, - callback=params.get('callback'), + async=params.get('async'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), @@ -132,22 +124,18 @@ class FakeApi(object): """ Test serialization of object with outer number type This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_composite_serialize(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_composite_serialize(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterComposite body: Input composite as post body :return: OuterComposite If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): + if kwargs.get('async'): return self.fake_outer_composite_serialize_with_http_info(**kwargs) else: (data) = self.fake_outer_composite_serialize_with_http_info(**kwargs) @@ -157,15 +145,11 @@ class FakeApi(object): """ Test serialization of object with outer number type This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_composite_serialize_with_http_info(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_composite_serialize_with_http_info(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterComposite body: Input composite as post body :return: OuterComposite If the method is called asynchronously, @@ -173,7 +157,7 @@ class FakeApi(object): """ all_params = ['body'] - all_params.append('callback') + all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') @@ -215,7 +199,7 @@ class FakeApi(object): files=local_var_files, response_type='OuterComposite', auth_settings=auth_settings, - callback=params.get('callback'), + async=params.get('async'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), @@ -225,22 +209,18 @@ class FakeApi(object): """ Test serialization of outer number types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_number_serialize(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_number_serialize(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterNumber body: Input number as post body :return: OuterNumber If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): + if kwargs.get('async'): return self.fake_outer_number_serialize_with_http_info(**kwargs) else: (data) = self.fake_outer_number_serialize_with_http_info(**kwargs) @@ -250,15 +230,11 @@ class FakeApi(object): """ Test serialization of outer number types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_number_serialize_with_http_info(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_number_serialize_with_http_info(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterNumber body: Input number as post body :return: OuterNumber If the method is called asynchronously, @@ -266,7 +242,7 @@ class FakeApi(object): """ all_params = ['body'] - all_params.append('callback') + all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') @@ -308,7 +284,7 @@ class FakeApi(object): files=local_var_files, response_type='OuterNumber', auth_settings=auth_settings, - callback=params.get('callback'), + async=params.get('async'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), @@ -318,22 +294,18 @@ class FakeApi(object): """ Test serialization of outer string types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_string_serialize(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_string_serialize(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterString body: Input string as post body :return: OuterString If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('callback'): + if kwargs.get('async'): return self.fake_outer_string_serialize_with_http_info(**kwargs) else: (data) = self.fake_outer_string_serialize_with_http_info(**kwargs) @@ -343,15 +315,11 @@ class FakeApi(object): """ Test serialization of outer string types This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please define a `callback` function - to be invoked when receiving the response. - >>> def callback_function(response): - >>> pprint(response) - >>> - >>> thread = api.fake_outer_string_serialize_with_http_info(callback=callback_function) + asynchronous HTTP request, please pass async=True + >>> thread = api.fake_outer_string_serialize_with_http_info(async=True) + >>> result = thread.get() - :param callback function: The callback function - for asynchronous request. (optional) + :param async bool :param OuterString body: Input string as post body :return: OuterString If the method is called asynchronously, @@ -359,7 +327,7 @@ class FakeApi(object): """ all_params = ['body'] - all_params.append('callback') + all_params.append('async') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') @@ -401,7 +369,7 @@ class FakeApi(object): files=local_var_files, response_type='OuterString', auth_settings=auth_settings, - callback=params.get('callback'), + async=params.get('async'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), @@ -815,3 +783,104 @@ class FakeApi(object): _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + + def test_json_form_data(self, param, param2, **kwargs): + """ + test json serialization of form data + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.test_json_form_data(param, param2, async=True) + >>> result = thread.get() + + :param async bool + :param str param: field1 (required) + :param str param2: field2 (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async'): + return self.test_json_form_data_with_http_info(param, param2, **kwargs) + else: + (data) = self.test_json_form_data_with_http_info(param, param2, **kwargs) + return data + + def test_json_form_data_with_http_info(self, param, param2, **kwargs): + """ + test json serialization of form data + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async=True + >>> thread = api.test_json_form_data_with_http_info(param, param2, async=True) + >>> result = thread.get() + + :param async bool + :param str param: field1 (required) + :param str param2: field2 (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['param', 'param2'] + all_params.append('async') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method test_json_form_data" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'param' is set + if ('param' not in params) or (params['param'] is None): + raise ValueError("Missing the required parameter `param` when calling `test_json_form_data`") + # verify the required parameter 'param2' is set + if ('param2' not in params) or (params['param2'] is None): + raise ValueError("Missing the required parameter `param2` when calling `test_json_form_data`") + + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + if 'param' in params: + form_params.append(('param', params['param'])) + if 'param2' in params: + form_params.append(('param2', params['param2'])) + + body_params = None + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['application/json']) + + # Authentication setting + auth_settings = [] + + return self.api_client.call_api('/fake/jsonFormData', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, + auth_settings=auth_settings, + async=params.get('async'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/samples/client/petstore/python/petstore_api/apis/fake_classname_tags_123_api.py b/samples/client/petstore/python/petstore_api/apis/fake_classname_tags_123_api.py index 48e803ffd24..5c1b91139d7 100644 --- a/samples/client/petstore/python/petstore_api/apis/fake_classname_tags_123_api.py +++ b/samples/client/petstore/python/petstore_api/apis/fake_classname_tags_123_api.py @@ -95,7 +95,7 @@ class FakeClassnameTags123Api(object): path_params = {} - query_params = {} + query_params = [] header_params = {} diff --git a/samples/client/petstore/python/petstore_api/models/format_test.py b/samples/client/petstore/python/petstore_api/models/format_test.py index b5afc2e4815..3a6f07ea254 100644 --- a/samples/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/client/petstore/python/petstore_api/models/format_test.py @@ -295,6 +295,8 @@ class FormatTest(object): """ if byte is None: raise ValueError("Invalid value for `byte`, must not be `None`") + if byte is not None and not re.search('^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', byte): + raise ValueError("Invalid value for `byte`, must be a follow pattern or equal to `/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/`") self._byte = byte diff --git a/samples/client/petstore/python/test/test_fake_classname_tags_123_api.py b/samples/client/petstore/python/test/test_fake_classname_tags_123_api.py new file mode 100644 index 00000000000..7a11a2378bf --- /dev/null +++ b/samples/client/petstore/python/test/test_fake_classname_tags_123_api.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +""" + Swagger 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: \" \\ + + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +import os +import sys +import unittest + +import petstore_api +from petstore_api.rest import ApiException +from petstore_api.apis.fake_classname_tags_123_api import FakeClassnameTags123Api + + +class TestFakeClassnameTags123Api(unittest.TestCase): + """ FakeClassnameTags123Api unit test stubs """ + + def setUp(self): + self.api = petstore_api.apis.fake_classname_tags_123_api.FakeClassnameTags123Api() + + def tearDown(self): + pass + + def test_test_classname(self): + """ + Test case for test_classname + + To test class name in snake case + """ + pass + + +if __name__ == '__main__': + unittest.main()