diff --git a/modules/openapi-generator/src/main/resources/python/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/model_utils.mustache index 07b77a99d18..396948e0a35 100644 --- a/modules/openapi-generator/src/main/resources/python/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_utils.mustache @@ -1211,13 +1211,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - 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] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index bd29a22a5f9..dc3743a492a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1286,6 +1286,66 @@ paths: application/json: schema: $ref: '#/components/schemas/HealthCheckResult' + /fake/getInlineAdditionalPropertiesRefPayload: + get: + tags: + - fake + operationId: getInlineAdditionalPropertiesRefPayload + responses: + 200: + description: InlineAdditionalPropertiesRefPayload + content: + application/json: + schema: + $ref: '#/components/schemas/InlineAdditionalPropertiesRefPayload' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InlineAdditionalPropertiesRefPayload' + /fake/getInlineAdditionalPropertiesPayload: + get: + tags: + - fake + operationId: getInlineAdditionalPropertiesPayload + responses: + 200: + description: InlineAdditionalPropertiesPayload + content: + application/json: + schema: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true + requestBody: + content: + application/json: + schema: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true servers: - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server @@ -2318,3 +2378,18 @@ components: SomeObject: allOf: - $ref: '#/components/schemas/ObjectInterface' + InlineAdditionalPropertiesRefPayload: + description: this payload is used for verification that some model_to_dict issues are fixed + type: object + properties: + arrayData: + type: array + nullable: true + items: + type: object + properties: + labels: + type: array + items: + type: string + nullable: true \ No newline at end of file diff --git a/samples/client/petstore/python/petstore_api/model_utils.py b/samples/client/petstore/python/petstore_api/model_utils.py index ae554710670..11a6cbf2d1b 100644 --- a/samples/client/petstore/python/petstore_api/model_utils.py +++ b/samples/client/petstore/python/petstore_api/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - 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] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py index 3276615fd49..84c8c74a7f6 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python/x_auth_id_alias/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - 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] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py index 7edd9487c37..6bb0bd10234 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - 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] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index aa906bc845d..a6f26c9c81f 100644 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -39,6 +39,7 @@ docs/EnumTest.md docs/EquilateralTriangle.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md docs/File.md docs/FileSchemaTestClass.md docs/Foo.md @@ -49,6 +50,8 @@ docs/GmFruit.md docs/GrandparentAnimal.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md +docs/InlineAdditionalPropertiesRefPayload.md +docs/InlineObject6.md docs/InlineResponseDefault.md docs/IntegerEnum.md docs/IntegerEnumOneValue.md @@ -142,6 +145,7 @@ petstore_api/model/enum_arrays.py petstore_api/model/enum_class.py petstore_api/model/enum_test.py petstore_api/model/equilateral_triangle.py +petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py petstore_api/model/file.py petstore_api/model/file_schema_test_class.py petstore_api/model/foo.py @@ -152,6 +156,8 @@ petstore_api/model/gm_fruit.py petstore_api/model/grandparent_animal.py petstore_api/model/has_only_read_only.py petstore_api/model/health_check_result.py +petstore_api/model/inline_additional_properties_ref_payload.py +petstore_api/model/inline_object6.py petstore_api/model/inline_response_default.py petstore_api/model/integer_enum.py petstore_api/model/integer_enum_one_value.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 61aebac0aa1..49e1220659f 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -91,6 +91,8 @@ Class | Method | HTTP request | Description *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* | [**get_inline_additional_properties_payload**](docs/FakeApi.md#get_inline_additional_properties_payload) | **GET** /fake/getInlineAdditionalPropertiesPayload | +*FakeApi* | [**get_inline_additional_properties_ref_payload**](docs/FakeApi.md#get_inline_additional_properties_ref_payload) | **GET** /fake/getInlineAdditionalPropertiesRefPayload | *FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal | *FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number | *FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | @@ -165,6 +167,7 @@ Class | Method | HTTP request | Description - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) - [EquilateralTriangle](docs/EquilateralTriangle.md) + - [FakeGetInlineAdditionalPropertiesPayloadArrayData](docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [Foo](docs/Foo.md) @@ -175,6 +178,8 @@ Class | Method | HTTP request | Description - [GrandparentAnimal](docs/GrandparentAnimal.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [HealthCheckResult](docs/HealthCheckResult.md) + - [InlineAdditionalPropertiesRefPayload](docs/InlineAdditionalPropertiesRefPayload.md) + - [InlineObject6](docs/InlineObject6.md) - [InlineResponseDefault](docs/InlineResponseDefault.md) - [IntegerEnum](docs/IntegerEnum.md) - [IntegerEnumOneValue](docs/IntegerEnumOneValue.md) diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md index 3bb042e8845..acc41cb4899 100644 --- a/samples/openapi3/client/petstore/python/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md @@ -12,6 +12,8 @@ Method | HTTP request | Description [**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 +[**get_inline_additional_properties_payload**](FakeApi.md#get_inline_additional_properties_payload) | **GET** /fake/getInlineAdditionalPropertiesPayload | +[**get_inline_additional_properties_ref_payload**](FakeApi.md#get_inline_additional_properties_ref_payload) | **GET** /fake/getInlineAdditionalPropertiesRefPayload | [**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal | [**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number | [**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | @@ -562,6 +564,148 @@ 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) +# **get_inline_additional_properties_payload** +> InlineObject6 get_inline_additional_properties_payload() + + + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.inline_object6 import InlineObject6 +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) + inline_object6 = InlineObject6( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData( + labels=[ + "labels_example", + ], + ), + ], + ) # InlineObject6 | (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.get_inline_additional_properties_payload(inline_object6=inline_object6) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->get_inline_additional_properties_payload: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **inline_object6** | [**InlineObject6**](InlineObject6.md)| | [optional] + +### Return type + +[**InlineObject6**](InlineObject6.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | InlineAdditionalPropertiesPayload | - | + +[[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) + +# **get_inline_additional_properties_ref_payload** +> InlineAdditionalPropertiesRefPayload get_inline_additional_properties_ref_payload() + + + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +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) + inline_additional_properties_ref_payload = InlineAdditionalPropertiesRefPayload( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData( + labels=[ + "labels_example", + ], + ), + ], + ) # InlineAdditionalPropertiesRefPayload | (optional) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.get_inline_additional_properties_ref_payload(inline_additional_properties_ref_payload=inline_additional_properties_ref_payload) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->get_inline_additional_properties_ref_payload: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **inline_additional_properties_ref_payload** | [**InlineAdditionalPropertiesRefPayload**](InlineAdditionalPropertiesRefPayload.md)| | [optional] + +### Return type + +[**InlineAdditionalPropertiesRefPayload**](InlineAdditionalPropertiesRefPayload.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | InlineAdditionalPropertiesRefPayload | - | + +[[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) + # **mammal** > Mammal mammal(mammal) diff --git a/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md b/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md new file mode 100644 index 00000000000..0ba4e3b8e5a --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/FakeGetInlineAdditionalPropertiesPayloadArrayData.md @@ -0,0 +1,11 @@ +# FakeGetInlineAdditionalPropertiesPayloadArrayData + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**labels** | **[str, none_type]** | | [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) + + diff --git a/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md b/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md new file mode 100644 index 00000000000..130320d1daa --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/InlineAdditionalPropertiesRefPayload.md @@ -0,0 +1,12 @@ +# InlineAdditionalPropertiesRefPayload + +this payload is used for verification that some model_to_dict issues are fixed + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_data** | [**[FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type**](FakeGetInlineAdditionalPropertiesPayloadArrayData.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) + + diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject6.md b/samples/openapi3/client/petstore/python/docs/InlineObject6.md new file mode 100644 index 00000000000..6e4975b3542 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/InlineObject6.md @@ -0,0 +1,12 @@ +# InlineObject6 + +this payload is used for verification that some model_to_dict issues are fixed + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_data** | [**[FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type**](FakeGetInlineAdditionalPropertiesPayloadArrayData.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) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 6baed5ea63d..5f98e228c3b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -30,6 +30,8 @@ from petstore_api.model.composed_one_of_number_with_validations import ComposedO 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.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +from petstore_api.model.inline_object6 import InlineObject6 from petstore_api.model.mammal import Mammal from petstore_api.model.number_with_validations import NumberWithValidations from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps @@ -943,6 +945,228 @@ class FakeApi(object): callable=__fake_health_get ) + def __get_inline_additional_properties_payload( + self, + **kwargs + ): + """get_inline_additional_properties_payload # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inline_additional_properties_payload(async_req=True) + >>> result = thread.get() + + + Keyword Args: + inline_object6 (InlineObject6): [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: + InlineObject6 + 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.get_inline_additional_properties_payload = _Endpoint( + settings={ + 'response_type': (InlineObject6,), + 'auth': [], + 'endpoint_path': '/fake/getInlineAdditionalPropertiesPayload', + 'operation_id': 'get_inline_additional_properties_payload', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'inline_object6', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'inline_object6': + (InlineObject6,), + }, + 'attribute_map': { + }, + 'location_map': { + 'inline_object6': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__get_inline_additional_properties_payload + ) + + def __get_inline_additional_properties_ref_payload( + self, + **kwargs + ): + """get_inline_additional_properties_ref_payload # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_inline_additional_properties_ref_payload(async_req=True) + >>> result = thread.get() + + + Keyword Args: + inline_additional_properties_ref_payload (InlineAdditionalPropertiesRefPayload): [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: + InlineAdditionalPropertiesRefPayload + 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.get_inline_additional_properties_ref_payload = _Endpoint( + settings={ + 'response_type': (InlineAdditionalPropertiesRefPayload,), + 'auth': [], + 'endpoint_path': '/fake/getInlineAdditionalPropertiesRefPayload', + 'operation_id': 'get_inline_additional_properties_ref_payload', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'inline_additional_properties_ref_payload', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'inline_additional_properties_ref_payload': + (InlineAdditionalPropertiesRefPayload,), + }, + 'attribute_map': { + }, + 'location_map': { + 'inline_additional_properties_ref_payload': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__get_inline_additional_properties_ref_payload + ) + def __mammal( self, mammal, diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py b/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py new file mode 100644 index 00000000000..bbbc449b429 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/fake_get_inline_additional_properties_payload_array_data.py @@ -0,0 +1,166 @@ +""" + 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 re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + + +class FakeGetInlineAdditionalPropertiesPayloadArrayData(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'labels': ([str, none_type],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'labels': 'labels', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """FakeGetInlineAdditionalPropertiesPayloadArrayData - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + labels ([str, none_type]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py b/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py new file mode 100644 index 00000000000..4d8e8aecff3 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/inline_additional_properties_ref_payload.py @@ -0,0 +1,171 @@ +""" + 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 re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class InlineAdditionalPropertiesRefPayload(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'array_data': ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_data': 'arrayData', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """InlineAdditionalPropertiesRefPayload - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_data ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py b/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py new file mode 100644 index 00000000000..d60fec5fa68 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/model/inline_object6.py @@ -0,0 +1,171 @@ +""" + 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 re # noqa: F401 +import sys # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) + +def lazy_import(): + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class InlineObject6(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + additional_properties_type = None + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'array_data': ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'array_data': 'arrayData', # noqa: E501 + } + + _composed_schemas = {} + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """InlineObject6 - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + array_data ([FakeGetInlineAdditionalPropertiesPayloadArrayData], none_type): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) diff --git a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py index ae554710670..11a6cbf2d1b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/model_utils.py +++ b/samples/openapi3/client/petstore/python/petstore_api/model_utils.py @@ -1493,13 +1493,19 @@ def model_to_dict(model_instance, serialize=True): # exist in attribute_map attr = model_instance.attribute_map.get(attr, attr) if isinstance(value, list): - 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] + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 4941dc7de6e..1d9f8235ac7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -42,6 +42,7 @@ from petstore_api.model.enum_arrays import EnumArrays from petstore_api.model.enum_class import EnumClass from petstore_api.model.enum_test import EnumTest from petstore_api.model.equilateral_triangle import EquilateralTriangle +from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData from petstore_api.model.file import File from petstore_api.model.file_schema_test_class import FileSchemaTestClass from petstore_api.model.foo import Foo @@ -52,6 +53,8 @@ from petstore_api.model.gm_fruit import GmFruit from petstore_api.model.grandparent_animal import GrandparentAnimal from petstore_api.model.has_only_read_only import HasOnlyReadOnly from petstore_api.model.health_check_result import HealthCheckResult +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload +from petstore_api.model.inline_object6 import InlineObject6 from petstore_api.model.inline_response_default import InlineResponseDefault from petstore_api.model.integer_enum import IntegerEnum from petstore_api.model.integer_enum_one_value import IntegerEnumOneValue diff --git a/samples/openapi3/client/petstore/python/test/test_fake_api.py b/samples/openapi3/client/petstore/python/test/test_fake_api.py index 48230221f42..8782dcd4c23 100644 --- a/samples/openapi3/client/petstore/python/test/test_fake_api.py +++ b/samples/openapi3/client/petstore/python/test/test_fake_api.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ OpenAPI Petstore @@ -57,6 +55,20 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_download_attachment(self): + """Test case for download_attachment + + downloads a file using Content-Disposition # noqa: E501 + """ + pass + + def test_enum_test(self): + """Test case for enum_test + + Object contains enum properties and array properties containing enums # noqa: E501 + """ + pass + def test_fake_health_get(self): """Test case for fake_health_get @@ -64,6 +76,18 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_get_inline_additionl_properties_ref_payload(self): + """Test case for get_inline_additionl_properties_ref_payload + + """ + pass + + def test_mammal(self): + """Test case for mammal + + """ + pass + def test_number_with_validations(self): """Test case for number_with_validations @@ -148,6 +172,27 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_upload_download_file(self): + """Test case for upload_download_file + + uploads a file and downloads a file using application/octet-stream # noqa: E501 + """ + pass + + def test_upload_file(self): + """Test case for upload_file + + uploads a file using multipart/form-data # noqa: E501 + """ + pass + + def test_upload_files(self): + """Test case for upload_files + + uploads files using multipart/form-data # noqa: E501 + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py b/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py new file mode 100644 index 00000000000..2e95eb37dff --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_fake_get_inline_additional_properties_payload_array_data.py @@ -0,0 +1,35 @@ +""" + 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.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + + +class TestFakeGetInlineAdditionalPropertiesPayloadArrayData(unittest.TestCase): + """FakeGetInlineAdditionalPropertiesPayloadArrayData unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testFakeGetInlineAdditionalPropertiesPayloadArrayData(self): + """Test FakeGetInlineAdditionalPropertiesPayloadArrayData""" + # FIXME: construct object with mandatory attributes with example values + # model = FakeGetInlineAdditionalPropertiesPayloadArrayData() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py b/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py new file mode 100644 index 00000000000..709ee27adc8 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_inline_additional_properties_ref_payload.py @@ -0,0 +1,37 @@ +""" + 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.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData +globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData +from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload + + +class TestInlineAdditionalPropertiesRefPayload(unittest.TestCase): + """InlineAdditionalPropertiesRefPayload unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testInlineAdditionalPropertiesRefPayload(self): + """Test InlineAdditionalPropertiesRefPayload""" + # FIXME: construct object with mandatory attributes with example values + # model = InlineAdditionalPropertiesRefPayload() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_inline_object6.py b/samples/openapi3/client/petstore/python/test/test_inline_object6.py new file mode 100644 index 00000000000..463123d8e55 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_inline_object6.py @@ -0,0 +1,37 @@ +""" + 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.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData +globals()['FakeGetInlineAdditionalPropertiesPayloadArrayData'] = FakeGetInlineAdditionalPropertiesPayloadArrayData +from petstore_api.model.inline_object6 import InlineObject6 + + +class TestInlineObject6(unittest.TestCase): + """InlineObject6 unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testInlineObject6(self): + """Test InlineObject6""" + # FIXME: construct object with mandatory attributes with example values + # model = InlineObject6() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py index 12fb6163684..8c0886e373b 100644 --- a/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py +++ b/samples/openapi3/client/petstore/python/tests_manual/test_fake_api.py @@ -604,6 +604,75 @@ class TestFakeApi(unittest.TestCase): """ pass + def test_get_inline_additional_properties_ref_payload(self): + """Test case for getInlineAdditionlPropertiesRefPayload + """ + from petstore_api.model.inline_additional_properties_ref_payload import InlineAdditionalPropertiesRefPayload + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + endpoint = self.api.get_inline_additional_properties_ref_payload + assert endpoint.openapi_types['inline_additional_properties_ref_payload'] == (InlineAdditionalPropertiesRefPayload,) + assert endpoint.settings['response_type'] == (InlineAdditionalPropertiesRefPayload,) + + # serialization + deserialization works + from petstore_api.rest import RESTClientObject, RESTResponse + with patch.object(RESTClientObject, 'request') as mock_method: + expected_json_body = { + 'array_data': [ + { + 'labels': [ + None, + 'foo' + ] + } + ] + } + inline_additional_properties_ref_payload = InlineAdditionalPropertiesRefPayload( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData(labels=[None, 'foo']) + ] + ) + mock_method.return_value = self.mock_response(expected_json_body) + + response = endpoint(inline_additional_properties_ref_payload=inline_additional_properties_ref_payload) + self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', body=expected_json_body) + + assert isinstance(response, InlineAdditionalPropertiesRefPayload) + assert response.to_dict() == expected_json_body + + def test_get_inline_additional_properties_payload(self): + """Test case for getInlineAdditionlPropertiesPayload + """ + from petstore_api.model.inline_object6 import InlineObject6 + from petstore_api.model.fake_get_inline_additional_properties_payload_array_data import FakeGetInlineAdditionalPropertiesPayloadArrayData + endpoint = self.api.get_inline_additional_properties_payload + assert endpoint.openapi_types['inline_object6'] == (InlineObject6,) + assert endpoint.settings['response_type'] == (InlineObject6,) + + # serialization + deserialization works + from petstore_api.rest import RESTClientObject, RESTResponse + with patch.object(RESTClientObject, 'request') as mock_method: + expected_json_body = { + 'array_data': [ + { + 'labels': [ + None, + 'foo' + ] + } + ] + } + inline_object6 = InlineObject6( + array_data=[ + FakeGetInlineAdditionalPropertiesPayloadArrayData(labels=[None, 'foo']) + ] + ) + mock_method.return_value = self.mock_response(expected_json_body) + + response = endpoint(inline_object6=inline_object6) + self.assert_request_called_with(mock_method, 'http://petstore.swagger.io:80/v2/fake/refs/enum', body=expected_json_body) + + assert isinstance(response, InlineObject6) + assert response.to_dict() == expected_json_body if __name__ == '__main__': unittest.main()