From d65339a800f2b166276588b4c45ee8a40f6d0f98 Mon Sep 17 00:00:00 2001 From: Ottmar Zittlau Date: Wed, 4 Mar 2026 18:02:30 +0100 Subject: [PATCH 1/3] Fix python template for list and dicts of dicts --- .../resources/python/model_generic.mustache | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) 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 034980befa0a..a5db75b50bdf 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -182,7 +182,21 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _dict['{{{baseName}}}'] = _items {{/items.items.isPrimitiveType}} {{/items.isArray}} + {{#items.isMap}} + {{^items.items.isPrimitiveType}} + # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list of dict) + _items = [] + if self.{{{name}}}: + for _item_{{{name}}} in self.{{{name}}}: + if _item_{{{name}}}: + _items.append( + {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_{{{name}}}.items()} + ) + _dict['{{{baseName}}}'] = _items + {{/items.items.isPrimitiveType}} + {{/items.isMap}} {{^items.isArray}} + {{^items.isMap}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list) @@ -194,6 +208,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _dict['{{{baseName}}}'] = _items {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} + {{/items.isMap}} {{/items.isArray}} {{/isArray}} {{#isMap}} @@ -210,6 +225,20 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} _dict['{{{baseName}}}'] = _field_dict_of_array {{/items.items.isPrimitiveType}} {{/items.isArray}} + {{#items.isMap}} + {{^items.items.isPrimitiveType}} + # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict of dict) + _field_dict_of_dict = {} + if self.{{{name}}}: + for _key_{{{name}}}, _value_{{{name}}} in self.{{{name}}}.items(): + if _value_{{{name}}} is not None: + _field_dict_of_dict[_key_{{{name}}}] = { + _key: _value.to_dict() for _key, _value in _value_{{{name}}}.items() + } + _dict['{{{baseName}}}'] = _field_dict_of_dict + {{/items.items.isPrimitiveType}} + {{/items.isMap}} + {{^items.isMap}} {{^items.isArray}} {{^items.isPrimitiveType}} {{^items.isEnumOrRef}} @@ -223,6 +252,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} {{/items.isArray}} + {{/items.isMap}} {{/isMap}} {{/isContainer}} {{^isContainer}} @@ -293,6 +323,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#allVars}} {{#isContainer}} {{#isArray}} + {{#items.isContainer}} {{#items.isArray}} {{#items.items.isPrimitiveType}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} @@ -304,7 +335,19 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} {{/items.isArray}} - {{^items.isArray}} + {{#items.isMap}} + {{#items.items.isPrimitiveType}} + "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{^items.items.isPrimitiveType}} + "{{{baseName}}}": [ + {_inner_key: {{{items.items.dataType}}}.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + for _item in obj["{{{baseName}}}"] + ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + {{/items.items.isPrimitiveType}} + {{/items.isMap}} + {{/items.isContainer}} + {{^items.isContainer}} {{^items.isPrimitiveType}} {{#items.isEnumOrRef}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} @@ -316,7 +359,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#items.isPrimitiveType}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} {{/items.isPrimitiveType}} - {{/items.isArray}} + {{/items.isContainer}} {{/isArray}} {{#isMap}} {{^items.isPrimitiveType}} @@ -331,7 +374,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if _v is not None else None ) - for _k, _v in obj.get("{{{baseName}}}").items() + for _k, _v in obj["{{{baseName}}}"].items() ) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} From 0a3ab52e87563ceac1662b267f2ddbbbe58fb0a8 Mon Sep 17 00:00:00 2001 From: Ottmar Zittlau Date: Wed, 4 Mar 2026 23:18:16 +0100 Subject: [PATCH 2/3] Add test cases for dict of dict and list of dict --- ...re-with-fake-endpoints-models-for-testing.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 59981307ff9e..2c10d7d5d36c 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 @@ -2137,6 +2137,12 @@ components: type: object additionalProperties: type: string + map_of_map_non_primitive_property: + type: object + additionalProperties: + type: object + additionalProperties: + $ref: '#/components/schemas/Pet' MixedPropertiesAndAdditionalPropertiesClass: type: object properties: @@ -2705,6 +2711,15 @@ components: type: array items: $ref: "#/components/schemas/Tag" + ArrayOfMapModel: + type: object + properties: + array_of_map_property: + type: array + items: + type: object + additionalProperties: + $ref: "#/components/schemas/Tag" ArrayOfArrayOfModel: type: object properties: From 7c1a8fd6afb63b7bacf6b11a3b45a21b7274e410 Mon Sep 17 00:00:00 2001 From: Ottmar Zittlau Date: Wed, 4 Mar 2026 23:18:59 +0100 Subject: [PATCH 3/3] Add generated samples --- .../python-aiohttp/.openapi-generator/FILES | 2 + .../client/petstore/python-aiohttp/README.md | 1 + .../docs/AdditionalPropertiesClass.md | 1 + .../python-aiohttp/docs/ArrayOfMapModel.md | 29 +++++ .../python-aiohttp/petstore_api/__init__.py | 2 + .../petstore_api/models/__init__.py | 1 + .../models/additional_properties_class.py | 27 ++++- .../petstore_api/models/array_of_map_model.py | 101 ++++++++++++++++ .../test/test_array_of_map_model.py | 55 +++++++++ .../python-httpx/.openapi-generator/FILES | 2 + .../client/petstore/python-httpx/README.md | 1 + .../docs/AdditionalPropertiesClass.md | 1 + .../python-httpx/docs/ArrayOfMapModel.md | 29 +++++ .../python-httpx/petstore_api/__init__.py | 2 + .../petstore_api/models/__init__.py | 1 + .../models/additional_properties_class.py | 27 ++++- .../petstore_api/models/array_of_map_model.py | 101 ++++++++++++++++ .../test/test_array_of_map_model.py | 55 +++++++++ .../.openapi-generator/FILES | 2 + .../petstore/python-lazyImports/README.md | 1 + .../docs/AdditionalPropertiesClass.md | 1 + .../docs/ArrayOfMapModel.md | 29 +++++ .../petstore_api/__init__.py | 3 + .../petstore_api/models/__init__.py | 2 + .../models/additional_properties_class.py | 27 ++++- .../petstore_api/models/array_of_map_model.py | 114 ++++++++++++++++++ .../test/test_array_of_map_model.py | 55 +++++++++ .../.openapi-generator/FILES | 2 + .../python-pydantic-v1-aiohttp/README.md | 1 + .../docs/AdditionalPropertiesClass.md | 1 + .../docs/ArrayOfMapModel.md | 28 +++++ .../petstore_api/__init__.py | 2 + .../petstore_api/models/__init__.py | 1 + .../models/additional_properties_class.py | 25 +++- .../petstore_api/models/array_of_map_model.py | 79 ++++++++++++ .../test/test_array_of_map_model.py | 56 +++++++++ .../.openapi-generator/FILES | 2 + .../petstore/python-pydantic-v1/README.md | 1 + .../docs/AdditionalPropertiesClass.md | 1 + .../docs/ArrayOfMapModel.md | 28 +++++ .../petstore_api/__init__.py | 2 + .../petstore_api/models/__init__.py | 1 + .../models/additional_properties_class.py | 25 +++- .../petstore_api/models/array_of_map_model.py | 91 ++++++++++++++ .../test/test_array_of_map_model.py | 56 +++++++++ .../petstore/python/.openapi-generator/FILES | 2 + .../openapi3/client/petstore/python/README.md | 1 + .../python/docs/AdditionalPropertiesClass.md | 1 + .../petstore/python/docs/ArrayOfMapModel.md | 29 +++++ .../petstore/python/petstore_api/__init__.py | 2 + .../python/petstore_api/models/__init__.py | 1 + .../models/additional_properties_class.py | 27 ++++- .../petstore_api/models/array_of_map_model.py | 114 ++++++++++++++++++ .../python/test/test_array_of_map_model.py | 55 +++++++++ 54 files changed, 1294 insertions(+), 12 deletions(-) create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-httpx/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-httpx/test/test_array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-lazyImports/test/test_array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python/docs/ArrayOfMapModel.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py create mode 100644 samples/openapi3/client/petstore/python/test/test_array_of_map_model.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index bb4378cdc76f..1eb565d74f11 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/AnyOfColor.md docs/AnyOfPig.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -151,6 +152,7 @@ petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index c9f1788c4055..287062971411 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -162,6 +162,7 @@ Class | Method | HTTP request | Description - [AnyOfPig](docs/AnyOfPig.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md index 8d4c08707f55..5128004d8f9a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..fd39f86fce5e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfMapModel.md @@ -0,0 +1,29 @@ +# ArrayOfMapModel + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print(ArrayOfMapModel.to_json()) + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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 640a87eab6ce..c7f461775f59 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -47,6 +47,7 @@ "AnyOfPig", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -185,6 +186,7 @@ from petstore_api.models.any_of_pig import AnyOfPig as AnyOfPig from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator 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 5905c3491fbe..308e6dfc3ebb 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 @@ -24,6 +24,7 @@ from petstore_api.models.any_of_pig import AnyOfPig 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index 8667aa3e9566..b59d93a55993 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.pet import Pet from typing import Optional, Set from typing_extensions import Self @@ -28,7 +29,8 @@ class AdditionalPropertiesClass(BaseModel): """ # noqa: E501 map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None - __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property"] + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None + __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] model_config = ConfigDict( validate_by_name=True, @@ -70,6 +72,15 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict of dict) + _field_dict_of_dict = {} + if self.map_of_map_non_primitive_property: + for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): + if _value_map_of_map_non_primitive_property is not None: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() + } + _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict return _dict @classmethod @@ -83,7 +94,19 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj["map_of_map_non_primitive_property"].items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..7ce18eb54fa9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_map_model.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.tag import Tag +from typing import Optional, Set +from typing_extensions import Self + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ # noqa: E501 + array_of_map_property: Optional[List[Dict[str, Tag]]] = None + __properties: ClassVar[List[str]] = ["array_of_map_property"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in array_of_map_property (list of dict) + _items = [] + if self.array_of_map_property: + for _item_array_of_map_property in self.array_of_map_property: + if _item_array_of_map_property: + _items.append( + {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + ) + _dict['array_of_map_property'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "array_of_map_property": [ + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + for _item in obj["array_of_map_property"] + ] if obj.get("array_of_map_property") is not None else None + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_map_model.py new file mode 100644 index 000000000000..fc232dcad462 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_array_of_map_model.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + include_optional 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # 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-httpx/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES index bb4378cdc76f..1eb565d74f11 100644 --- a/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/AnyOfColor.md docs/AnyOfPig.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -151,6 +152,7 @@ petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python-httpx/README.md b/samples/openapi3/client/petstore/python-httpx/README.md index c9f1788c4055..287062971411 100644 --- a/samples/openapi3/client/petstore/python-httpx/README.md +++ b/samples/openapi3/client/petstore/python-httpx/README.md @@ -162,6 +162,7 @@ Class | Method | HTTP request | Description - [AnyOfPig](docs/AnyOfPig.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md index 8d4c08707f55..5128004d8f9a 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..fd39f86fce5e --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfMapModel.md @@ -0,0 +1,29 @@ +# ArrayOfMapModel + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print(ArrayOfMapModel.to_json()) + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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-httpx/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py index 640a87eab6ce..c7f461775f59 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py @@ -47,6 +47,7 @@ "AnyOfPig", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -185,6 +186,7 @@ from petstore_api.models.any_of_pig import AnyOfPig as AnyOfPig from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py index 5905c3491fbe..308e6dfc3ebb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py @@ -24,6 +24,7 @@ from petstore_api.models.any_of_pig import AnyOfPig 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index 8667aa3e9566..b59d93a55993 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.pet import Pet from typing import Optional, Set from typing_extensions import Self @@ -28,7 +29,8 @@ class AdditionalPropertiesClass(BaseModel): """ # noqa: E501 map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None - __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property"] + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None + __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] model_config = ConfigDict( validate_by_name=True, @@ -70,6 +72,15 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict of dict) + _field_dict_of_dict = {} + if self.map_of_map_non_primitive_property: + for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): + if _value_map_of_map_non_primitive_property is not None: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() + } + _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict return _dict @classmethod @@ -83,7 +94,19 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj["map_of_map_non_primitive_property"].items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..7ce18eb54fa9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_map_model.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.tag import Tag +from typing import Optional, Set +from typing_extensions import Self + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ # noqa: E501 + array_of_map_property: Optional[List[Dict[str, Tag]]] = None + __properties: ClassVar[List[str]] = ["array_of_map_property"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in array_of_map_property (list of dict) + _items = [] + if self.array_of_map_property: + for _item_array_of_map_property in self.array_of_map_property: + if _item_array_of_map_property: + _items.append( + {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + ) + _dict['array_of_map_property'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "array_of_map_property": [ + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + for _item in obj["array_of_map_property"] + ] if obj.get("array_of_map_property") is not None else None + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-httpx/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python-httpx/test/test_array_of_map_model.py new file mode 100644 index 000000000000..fc232dcad462 --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/test/test_array_of_map_model.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + include_optional 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # 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-lazyImports/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES index bb4378cdc76f..1eb565d74f11 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/AnyOfColor.md docs/AnyOfPig.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -151,6 +152,7 @@ petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python-lazyImports/README.md b/samples/openapi3/client/petstore/python-lazyImports/README.md index 41639a16e6b0..48d92a57f21e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/README.md +++ b/samples/openapi3/client/petstore/python-lazyImports/README.md @@ -162,6 +162,7 @@ Class | Method | HTTP request | Description - [AnyOfPig](docs/AnyOfPig.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md index 8d4c08707f55..5128004d8f9a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..fd39f86fce5e --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfMapModel.md @@ -0,0 +1,29 @@ +# ArrayOfMapModel + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print(ArrayOfMapModel.to_json()) + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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-lazyImports/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py index af6c0b572aba..64ad7b567d1a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py @@ -47,6 +47,7 @@ "AnyOfPig", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -186,6 +187,7 @@ from petstore_api.models.any_of_pig import AnyOfPig as AnyOfPig from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly + from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator @@ -331,6 +333,7 @@ from petstore_api.models.any_of_pig import AnyOfPig as AnyOfPig from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py index 0d20f338b700..9f052c816cb7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py @@ -25,6 +25,7 @@ from petstore_api.models.any_of_pig import AnyOfPig 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator @@ -146,6 +147,7 @@ from petstore_api.models.any_of_pig import AnyOfPig 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index cf868afd6446..0e5e49f00458 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.pet import Pet from typing import Optional, Set from typing_extensions import Self @@ -28,8 +29,9 @@ class AdditionalPropertiesClass(BaseModel): """ # noqa: E501 map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property"] + __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] model_config = ConfigDict( validate_by_name=True, @@ -73,6 +75,15 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict of dict) + _field_dict_of_dict = {} + if self.map_of_map_non_primitive_property: + for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): + if _value_map_of_map_non_primitive_property is not None: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() + } + _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict # 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(): @@ -91,7 +102,19 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj["map_of_map_non_primitive_property"].items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..e06e01989440 --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_map_model.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.tag import Tag +from typing import Optional, Set +from typing_extensions import Self + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ # noqa: E501 + array_of_map_property: Optional[List[Dict[str, Tag]]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["array_of_map_property"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in array_of_map_property (list of dict) + _items = [] + if self.array_of_map_property: + for _item_array_of_map_property in self.array_of_map_property: + if _item_array_of_map_property: + _items.append( + {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + ) + _dict['array_of_map_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: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "array_of_map_property": [ + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + for _item in obj["array_of_map_property"] + ] if obj.get("array_of_map_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-lazyImports/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python-lazyImports/test/test_array_of_map_model.py new file mode 100644 index 000000000000..fc232dcad462 --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/test/test_array_of_map_model.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + include_optional 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # 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-pydantic-v1-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES index c65b8d1ce8d6..3bdfdd3eebd9 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES @@ -16,6 +16,7 @@ docs/AnyOfPig.md docs/ApiResponse.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -152,6 +153,7 @@ 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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md index 62e72d704d7e..ffcee520f0e4 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -164,6 +164,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/AdditionalPropertiesClass.md index 88b80a675ffd..5517244bc67f 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/AdditionalPropertiesClass.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..23cbeb599569 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/ArrayOfMapModel.md @@ -0,0 +1,28 @@ +# ArrayOfMapModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print ArrayOfMapModel.to_json() + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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-pydantic-v1-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py index f75dcba11e78..e89049d66426 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py @@ -48,6 +48,7 @@ "ApiResponse", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -186,6 +187,7 @@ from petstore_api.models.api_response import ApiResponse as ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py index e411da71f2cd..51cf981e4b26 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py @@ -26,6 +26,7 @@ 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/additional_properties_class.py index c53af3e2ca67..45c279def9fb 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/additional_properties_class.py @@ -20,6 +20,7 @@ from typing import Dict, Optional from pydantic import BaseModel, StrictStr +from petstore_api.models.pet import Pet class AdditionalPropertiesClass(BaseModel): """ @@ -27,7 +28,8 @@ class AdditionalPropertiesClass(BaseModel): """ map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None - __properties = ["map_property", "map_of_map_property"] + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None + __properties = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] class Config: """Pydantic configuration""" @@ -53,6 +55,13 @@ def to_dict(self): exclude={ }, exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict) + _field_dict = {} + if self.map_of_map_non_primitive_property: + for _key in self.map_of_map_non_primitive_property: + if self.map_of_map_non_primitive_property[_key]: + _field_dict[_key] = self.map_of_map_non_primitive_property[_key].to_dict() + _dict['map_of_map_non_primitive_property'] = _field_dict return _dict @classmethod @@ -66,7 +75,19 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: _obj = AdditionalPropertiesClass.parse_obj({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj.get("map_of_map_non_primitive_property").items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..d701c96c0906 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/array_of_map_model.py @@ -0,0 +1,79 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Dict, List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.tag import Tag + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ + array_of_map_property: Optional[conlist(Dict[str, Tag])] = None + __properties = ["array_of_map_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) -> ArrayOfMapModel: + """Create an instance of ArrayOfMapModel 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 array_of_map_property (list) + _items = [] + if self.array_of_map_property: + for _item in self.array_of_map_property: + if _item: + _items.append(_item.to_dict()) + _dict['array_of_map_property'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> ArrayOfMapModel: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfMapModel.parse_obj(obj) + + _obj = ArrayOfMapModel.parse_obj({ + "array_of_map_property": [Dict[str, Tag].from_dict(_item) for _item in obj.get("array_of_map_property")] if obj.get("array_of_map_property") is not None else None + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_array_of_map_model.py new file mode 100644 index 000000000000..5384b50b7789 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_array_of_map_model.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.array_of_map_model import ArrayOfMapModel # noqa: E501 + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() # noqa: E501 + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # 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-pydantic-v1/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES index c65b8d1ce8d6..3bdfdd3eebd9 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -16,6 +16,7 @@ docs/AnyOfPig.md docs/ApiResponse.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -152,6 +153,7 @@ 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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 49cb5abf6e59..238d2ed74e39 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -164,6 +164,7 @@ Class | Method | HTTP request | Description - [ApiResponse](docs/ApiResponse.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/AdditionalPropertiesClass.md index 88b80a675ffd..5517244bc67f 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/AdditionalPropertiesClass.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..23cbeb599569 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/ArrayOfMapModel.md @@ -0,0 +1,28 @@ +# ArrayOfMapModel + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print ArrayOfMapModel.to_json() + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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-pydantic-v1/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py index f75dcba11e78..e89049d66426 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py @@ -48,6 +48,7 @@ "ApiResponse", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -186,6 +187,7 @@ from petstore_api.models.api_response import ApiResponse as ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py index e411da71f2cd..51cf981e4b26 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py @@ -26,6 +26,7 @@ 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/additional_properties_class.py index 06c924e21f91..ce7f934a1d97 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/additional_properties_class.py @@ -20,6 +20,7 @@ from typing import Any, Dict, Optional from pydantic import BaseModel, StrictStr +from petstore_api.models.pet import Pet class AdditionalPropertiesClass(BaseModel): """ @@ -27,8 +28,9 @@ class AdditionalPropertiesClass(BaseModel): """ map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None additional_properties: Dict[str, Any] = {} - __properties = ["map_property", "map_of_map_property"] + __properties = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] class Config: """Pydantic configuration""" @@ -55,6 +57,13 @@ def to_dict(self): "additional_properties" }, exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict) + _field_dict = {} + if self.map_of_map_non_primitive_property: + for _key in self.map_of_map_non_primitive_property: + if self.map_of_map_non_primitive_property[_key]: + _field_dict[_key] = self.map_of_map_non_primitive_property[_key].to_dict() + _dict['map_of_map_non_primitive_property'] = _field_dict # 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(): @@ -73,7 +82,19 @@ def from_dict(cls, obj: dict) -> AdditionalPropertiesClass: _obj = AdditionalPropertiesClass.parse_obj({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj.get("map_of_map_non_primitive_property").items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..4e57865b8b59 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/array_of_map_model.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, List, Optional +from pydantic import BaseModel, conlist +from petstore_api.models.tag import Tag + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ + array_of_map_property: Optional[conlist(Dict[str, Tag])] = None + additional_properties: Dict[str, Any] = {} + __properties = ["array_of_map_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) -> ArrayOfMapModel: + """Create an instance of ArrayOfMapModel 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 array_of_map_property (list) + _items = [] + if self.array_of_map_property: + for _item in self.array_of_map_property: + if _item: + _items.append(_item.to_dict()) + _dict['array_of_map_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) -> ArrayOfMapModel: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return ArrayOfMapModel.parse_obj(obj) + + _obj = ArrayOfMapModel.parse_obj({ + "array_of_map_property": [Dict[str, Tag].from_dict(_item) for _item in obj.get("array_of_map_property")] if obj.get("array_of_map_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-pydantic-v1/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_array_of_map_model.py new file mode 100644 index 000000000000..5384b50b7789 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_array_of_map_model.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.array_of_map_model import ArrayOfMapModel # noqa: E501 + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() # noqa: E501 + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # 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 bb4378cdc76f..1eb565d74f11 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -15,6 +15,7 @@ docs/AnyOfColor.md docs/AnyOfPig.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md +docs/ArrayOfMapModel.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BaseDiscriminator.md @@ -151,6 +152,7 @@ petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.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_map_model.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/base_discriminator.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 41639a16e6b0..48d92a57f21e 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -162,6 +162,7 @@ Class | Method | HTTP request | Description - [AnyOfPig](docs/AnyOfPig.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfMapModel](docs/ArrayOfMapModel.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BaseDiscriminator](docs/BaseDiscriminator.md) diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md index 8d4c08707f55..5128004d8f9a 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_property** | **Dict[str, str]** | | [optional] **map_of_map_property** | **Dict[str, Dict[str, str]]** | | [optional] +**map_of_map_non_primitive_property** | **Dict[str, Dict[str, Pet]]** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfMapModel.md b/samples/openapi3/client/petstore/python/docs/ArrayOfMapModel.md new file mode 100644 index 000000000000..fd39f86fce5e --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfMapModel.md @@ -0,0 +1,29 @@ +# ArrayOfMapModel + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_map_property** | **List[Dict[str, Tag]]** | | [optional] + +## Example + +```python +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +# TODO update the JSON string below +json = "{}" +# create an instance of ArrayOfMapModel from a JSON string +array_of_map_model_instance = ArrayOfMapModel.from_json(json) +# print the JSON string representation of the object +print(ArrayOfMapModel.to_json()) + +# convert the object into a dict +array_of_map_model_dict = array_of_map_model_instance.to_dict() +# create an instance of ArrayOfMapModel from a dict +array_of_map_model_from_dict = ArrayOfMapModel.from_dict(array_of_map_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 640a87eab6ce..c7f461775f59 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -47,6 +47,7 @@ "AnyOfPig", "ArrayOfArrayOfModel", "ArrayOfArrayOfNumberOnly", + "ArrayOfMapModel", "ArrayOfNumberOnly", "ArrayTest", "BaseDiscriminator", @@ -185,6 +186,7 @@ from petstore_api.models.any_of_pig import AnyOfPig as AnyOfPig from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel as ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly as ArrayOfArrayOfNumberOnly +from petstore_api.models.array_of_map_model import ArrayOfMapModel as ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly as ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest as ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator as BaseDiscriminator 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 5905c3491fbe..308e6dfc3ebb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -24,6 +24,7 @@ from petstore_api.models.any_of_pig import AnyOfPig 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_map_model import ArrayOfMapModel from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.base_discriminator import BaseDiscriminator diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index cf868afd6446..0e5e49f00458 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.pet import Pet from typing import Optional, Set from typing_extensions import Self @@ -28,8 +29,9 @@ class AdditionalPropertiesClass(BaseModel): """ # noqa: E501 map_property: Optional[Dict[str, StrictStr]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None + map_of_map_non_primitive_property: Optional[Dict[str, Dict[str, Pet]]] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property"] + __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property", "map_of_map_non_primitive_property"] model_config = ConfigDict( validate_by_name=True, @@ -73,6 +75,15 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each value in map_of_map_non_primitive_property (dict of dict) + _field_dict_of_dict = {} + if self.map_of_map_non_primitive_property: + for _key_map_of_map_non_primitive_property, _value_map_of_map_non_primitive_property in self.map_of_map_non_primitive_property.items(): + if _value_map_of_map_non_primitive_property is not None: + _field_dict_of_dict[_key_map_of_map_non_primitive_property] = { + _key: _value.to_dict() for _key, _value in _value_map_of_map_non_primitive_property.items() + } + _dict['map_of_map_non_primitive_property'] = _field_dict_of_dict # 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(): @@ -91,7 +102,19 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") + "map_of_map_property": obj.get("map_of_map_property"), + "map_of_map_non_primitive_property": dict( + (_k, dict( + (_ik, Pet.from_dict(_iv)) + for _ik, _iv in _v.items() + ) + if _v is not None + else None + ) + for _k, _v in obj["map_of_map_non_primitive_property"].items() + ) + if obj.get("map_of_map_non_primitive_property") is not None + else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py new file mode 100644 index 000000000000..e06e01989440 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_map_model.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.tag import Tag +from typing import Optional, Set +from typing_extensions import Self + +class ArrayOfMapModel(BaseModel): + """ + ArrayOfMapModel + """ # noqa: E501 + array_of_map_property: Optional[List[Dict[str, Tag]]] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["array_of_map_property"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in array_of_map_property (list of dict) + _items = [] + if self.array_of_map_property: + for _item_array_of_map_property in self.array_of_map_property: + if _item_array_of_map_property: + _items.append( + {_inner_key: _inner_value.to_dict() for _inner_key, _inner_value in _item_array_of_map_property.items()} + ) + _dict['array_of_map_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: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ArrayOfMapModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "array_of_map_property": [ + {_inner_key: Tag.from_dict(_inner_value) for _inner_key, _inner_value in _item.items()} + for _item in obj["array_of_map_property"] + ] if obj.get("array_of_map_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/test/test_array_of_map_model.py b/samples/openapi3/client/petstore/python/test/test_array_of_map_model.py new file mode 100644 index 000000000000..fc232dcad462 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_array_of_map_model.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.array_of_map_model import ArrayOfMapModel + +class TestArrayOfMapModel(unittest.TestCase): + """ArrayOfMapModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ArrayOfMapModel: + """Test ArrayOfMapModel + include_optional 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 `ArrayOfMapModel` + """ + model = ArrayOfMapModel() + if include_optional: + return ArrayOfMapModel( + array_of_map_property = [ + { + 'key' : '' + } + ] + ) + else: + return ArrayOfMapModel( + ) + """ + + def testArrayOfMapModel(self): + """Test ArrayOfMapModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()