diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 670bb1ff2a3..0fa9768ba7b 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -138,6 +138,20 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#allVars}} {{#isContainer}} {{#isArray}} + {{#items.isArray}} + {{^items.items.isPrimitiveType}} + # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list of list) + _items = [] + if self.{{{name}}}: + for _item in self.{{{name}}}: + if _item: + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) + _dict['{{{baseName}}}'] = _items + {{/items.items.isPrimitiveType}} + {{/items.isArray}} + {{^items.isArray}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list) @@ -149,6 +163,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _dict['{{{baseName}}}'] = _items {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} + {{/items.isArray}} {{/isArray}} {{#isMap}} {{#items.isArray}} @@ -241,6 +256,18 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#allVars}} {{#isContainer}} {{#isArray}} + {{#items.isArray}} + {{#items.items.isPrimitiveType}} + "{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{^items.items.isPrimitiveType}} + "{{{name}}}": [ + [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("{{{baseName}}}") + ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{/items.isArray}} + {{^items.isArray}} {{^items.isPrimitiveType}} {{#items.isEnumOrRef}} "{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} @@ -252,6 +279,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#items.isPrimitiveType}} "{{{name}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} {{/items.isPrimitiveType}} + {{/items.isArray}} {{/isArray}} {{#isMap}} {{^items.isPrimitiveType}} diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index c64b41d52dc..c7c3818db45 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -2220,4 +2220,13 @@ components: type: array items: $ref: "#/components/schemas/Tag" + ArrayOfArrayOfModel: + type: object + properties: + another_property: + type: array + items: + type: array + items: + $ref: "#/components/schemas/Tag" diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 76ffc7107a3..8454047697e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -10,6 +10,7 @@ docs/AnotherFakeApi.md docs/AnyOfColor.md docs/AnyOfPig.md docs/ApiResponse.md +docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md @@ -100,6 +101,7 @@ petstore_api/models/animal.py petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.py petstore_api/models/api_response.py +petstore_api/models/array_of_array_of_model.py petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 1ddc3a23fae..bf92d983b1a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -138,6 +138,7 @@ Class | Method | HTTP request | Description - [AnyOfColor](docs/AnyOfColor.md) - [AnyOfPig](docs/AnyOfPig.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md new file mode 100644 index 00000000000..09406159261 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md @@ -0,0 +1,28 @@ +# ArrayOfArrayOfModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**another_property** | **List[List[Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfArrayOfModel from a JSON string +array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +# print the JSON string representation of the object +print ArrayOfArrayOfModel.to_json() + +# convert the object into a dict +array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +# create an instance of ArrayOfArrayOfModel from a dict +array_of_array_of_model_form_dict = array_of_array_of_model.from_dict(array_of_array_of_model_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) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index ddd03f53651..55f33527658 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -44,6 +44,7 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py index d78362da1c0..e33f0cfcd9d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py @@ -20,6 +20,7 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py new file mode 100644 index 00000000000..98d81af1350 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.tag import Tag + +class ArrayOfArrayOfModel(BaseModel): + """ + ArrayOfArrayOfModel + """ + another_property: Optional[conlist(conlist(Tag))] = None + __properties = ["another_property"] + + 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) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel 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) + # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) + _items = [] + if self.another_property: + for _item in self.another_property: + if _item: + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) + _dict['another_property'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfArrayOfModel.parse_obj(obj) + + _obj = ArrayOfArrayOfModel.parse_obj({ + "another_property": [ + [Tag.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("another_property") + ] if obj.get("another_property") is not None else None + }) + return _obj + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index e6775be1c70..4adcb06ff2d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -55,12 +55,14 @@ class ArrayTest(BaseModel): exclude={ }, exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list) + # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) _items = [] if self.array_array_of_model: for _item in self.array_array_of_model: if _item: - _items.append(_item.to_dict()) + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) _dict['array_array_of_model'] = _items return _dict @@ -76,7 +78,10 @@ class ArrayTest(BaseModel): _obj = ArrayTest.parse_obj({ "array_of_string": obj.get("array_of_string"), "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [List[ReadOnlyFirst].from_dict(_item) for _item in obj.get("array_array_of_model")] if obj.get("array_array_of_model") is not None else None + "array_array_of_model": [ + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("array_array_of_model") + ] if obj.get("array_array_of_model") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_array_of_model.py new file mode 100644 index 00000000000..06b560c4002 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_array_of_model.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayOfArrayOfModel(unittest.TestCase): + """ArrayOfArrayOfModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayOfArrayOfModel + 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 `ArrayOfArrayOfModel` + """ + model = petstore_api.models.array_of_array_of_model.ArrayOfArrayOfModel() # noqa: E501 + if include_optional : + return ArrayOfArrayOfModel( + another_property = [ + [ + petstore_api.models.tag.Tag( + id = 56, + name = '', ) + ] + ] + ) + else : + return ArrayOfArrayOfModel( + ) + """ + + def testArrayOfArrayOfModel(self): + """Test ArrayOfArrayOfModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 50c778e41d9..5e921908b2e 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -10,6 +10,7 @@ docs/AnotherFakeApi.md docs/AnyOfColor.md docs/AnyOfPig.md docs/ApiResponse.md +docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md @@ -100,6 +101,7 @@ petstore_api/models/animal.py petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.py petstore_api/models/api_response.py +petstore_api/models/array_of_array_of_model.py petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 7b834c7c4c6..8d4405273fa 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -138,6 +138,7 @@ Class | Method | HTTP request | Description - [AnyOfColor](docs/AnyOfColor.md) - [AnyOfPig](docs/AnyOfPig.md) - [ApiResponse](docs/ApiResponse.md) + - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md new file mode 100644 index 00000000000..09406159261 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md @@ -0,0 +1,28 @@ +# ArrayOfArrayOfModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**another_property** | **List[List[Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfArrayOfModel from a JSON string +array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +# print the JSON string representation of the object +print ArrayOfArrayOfModel.to_json() + +# convert the object into a dict +array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +# create an instance of ArrayOfArrayOfModel from a dict +array_of_array_of_model_form_dict = array_of_array_of_model.from_dict(array_of_array_of_model_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) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index ddd03f53651..55f33527658 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -44,6 +44,7 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest 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 d78362da1c0..e33f0cfcd9d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -20,6 +20,7 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig from petstore_api.models.api_response import ApiResponse +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py new file mode 100644 index 00000000000..346aacb8f60 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.tag import Tag + +class ArrayOfArrayOfModel(BaseModel): + """ + ArrayOfArrayOfModel + """ + another_property: Optional[conlist(conlist(Tag))] = None + additional_properties: Dict[str, Any] = {} + __properties = ["another_property"] + + 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) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel 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={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) + _items = [] + if self.another_property: + for _item in self.another_property: + if _item: + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) + _dict['another_property'] = _items + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfArrayOfModel: + """Create an instance of ArrayOfArrayOfModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfArrayOfModel.parse_obj(obj) + + _obj = ArrayOfArrayOfModel.parse_obj({ + "another_property": [ + [Tag.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("another_property") + ] if obj.get("another_property") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index afef8bee0fd..dcfd951e8d3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -57,12 +57,14 @@ class ArrayTest(BaseModel): "additional_properties" }, exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list) + # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) _items = [] if self.array_array_of_model: for _item in self.array_array_of_model: if _item: - _items.append(_item.to_dict()) + _items.append( + [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] + ) _dict['array_array_of_model'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: @@ -83,7 +85,10 @@ class ArrayTest(BaseModel): _obj = ArrayTest.parse_obj({ "array_of_string": obj.get("array_of_string"), "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [List[ReadOnlyFirst].from_dict(_item) for _item in obj.get("array_array_of_model")] if obj.get("array_array_of_model") is not None else None + "array_array_of_model": [ + [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] + for _item in obj.get("array_array_of_model") + ] if obj.get("array_array_of_model") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/test/test_array_of_array_of_model.py b/samples/openapi3/client/petstore/python/test/test_array_of_array_of_model.py new file mode 100644 index 00000000000..1072a19255d --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_array_of_array_of_model.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # noqa: E501 +from petstore_api.rest import ApiException + +class TestArrayOfArrayOfModel(unittest.TestCase): + """ArrayOfArrayOfModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test ArrayOfArrayOfModel + 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 `ArrayOfArrayOfModel` + """ + model = petstore_api.models.array_of_array_of_model.ArrayOfArrayOfModel() # noqa: E501 + if include_optional : + return ArrayOfArrayOfModel( + shop_id_to_org_online_lip_map = [ + [ + petstore_api.models.tag.Tag( + id = 56, + name = '', ) + ] + ] + ) + else : + return ArrayOfArrayOfModel( + ) + """ + + def testArrayOfArrayOfModel(self): + """Test ArrayOfArrayOfModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 6f47a375eab..dc8b13cdc9a 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -492,3 +492,12 @@ class ModelTests(unittest.TestCase): self.assertEqual(a.to_json(), '{"shopIdToOrgOnlineLipMap": {"somekey": [{"id": 123, "name": "tag name"}]}}') a2 = petstore_api.MapOfArrayOfModel.from_dict(a.to_dict()) self.assertEqual(a.to_dict(), a2.to_dict()) + + def test_array_of_array_of_model(self): + a = petstore_api.ArrayOfArrayOfModel() + t = petstore_api.Tag(id=123, name="tag name") + a.another_property = [[t]] + self.assertEqual(a.to_dict(), {'another_property': [[ {'id': 123, 'name': 'tag name'} ]]}) + self.assertEqual(a.to_json(), '{"another_property": [[{"id": 123, "name": "tag name"}]]}') + a2 = petstore_api.ArrayOfArrayOfModel.from_dict(a.to_dict()) + self.assertEqual(a.to_dict(), a2.to_dict())