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 a4d8a8081db..ca6372d2d90 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -182,15 +182,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isArray}} {{#isMap}} {{#items.isArray}} + {{^items.items.isPrimitiveType}} # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict of array) _field_dict_of_array = {} if self.{{{name}}}: for _key in self.{{{name}}}: - if self.{{{name}}}[_key]: + if self.{{{name}}}[_key] is not None: _field_dict_of_array[_key] = [ _item.to_dict() for _item in self.{{{name}}}[_key] ] _dict['{{{baseName}}}'] = _field_dict_of_array + {{/items.items.isPrimitiveType}} {{/items.isArray}} {{^items.isArray}} {{^items.isPrimitiveType}} diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index 2894fded0d1..6c6a10dc464 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 @@ -2351,3 +2351,21 @@ components: title: ListOfObjects items: $ref: "#/components/schemas/Tag" + UnnamedDictWithAdditionalStringListProperties: + type: object + properties: + dictProperty: + type: object + additionalProperties: + type: array + items: + type: string + UnnamedDictWithAdditionalModelListProperties: + type: object + properties: + dictProperty: + type: object + additionalProperties: + type: array + items: + $ref: "#/components/schemas/CreatureInfo" diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index b4bc51e0452..00dc818606f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -86,6 +86,8 @@ docs/StoreApi.md docs/Tag.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md +docs/UnnamedDictWithAdditionalModelListProperties.md +docs/UnnamedDictWithAdditionalStringListProperties.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -181,6 +183,8 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py +petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +petstore_api/models/unnamed_dict_with_additional_string_list_properties.py petstore_api/models/user.py petstore_api/models/with_nested_one_of.py petstore_api/py.typed diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 55eafdf48fc..88ea04ad16e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -212,6 +212,8 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) + - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) + - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md new file mode 100644 index 00000000000..c102bb86beb --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalModelListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[CreatureInfo]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalModelListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalModelListProperties from a dict +unnamed_dict_with_additional_model_list_properties_form_dict = unnamed_dict_with_additional_model_list_properties.from_dict(unnamed_dict_with_additional_model_list_properties_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/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md new file mode 100644 index 00000000000..926404ccd6e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalStringListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[str]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalStringListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalStringListProperties from a dict +unnamed_dict_with_additional_string_list_properties_form_dict = unnamed_dict_with_additional_string_list_properties.from_dict(unnamed_dict_with_additional_string_list_properties_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 69c88cf7525..c1c56eb8115 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -115,5 +115,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf 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 a00e5da5310..dd9388d355d 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 @@ -91,5 +91,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 2cb0f11baa2..ed7287da6db 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -75,7 +75,7 @@ class MapOfArrayOfModel(BaseModel): _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key]: + if self.shop_id_to_org_online_lip_map[_key] is not None: _field_dict_of_array[_key] = [ _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key] ] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..a96d8d1f8d3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,96 @@ +# 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 +from pydantic import Field +from petstore_api.models.creature_info import CreatureInfo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class UnnamedDictWithAdditionalModelListProperties(BaseModel): + """ + UnnamedDictWithAdditionalModelListProperties + """ + dict_property: Optional[Dict[str, List[CreatureInfo]]] = Field(default=None, alias="dictProperty") + __properties: ClassVar[List[str]] = ["dictProperty"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalModelListProperties 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.model_dump(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key] is not None: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Self: + """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "dictProperty": dict( + (_k, + [CreatureInfo.from_dict(_item) for _item in _v] + if _v is not None + else None + ) + for _k, _v in obj.get("dictProperty").items() + ) + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..17c897d2b56 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.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, StrictStr +from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class UnnamedDictWithAdditionalStringListProperties(BaseModel): + """ + UnnamedDictWithAdditionalStringListProperties + """ + dict_property: Optional[Dict[str, List[StrictStr]]] = Field(default=None, alias="dictProperty") + __properties: ClassVar[List[str]] = ["dictProperty"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalStringListProperties 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.model_dump(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Self: + """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "dictProperty": obj.get("dictProperty") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..64854cb7ee9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,57 @@ +# 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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalModelListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalModelListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalModelListProperties: + """Test UnnamedDictWithAdditionalModelListProperties + 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 `UnnamedDictWithAdditionalModelListProperties` + """ + model = UnnamedDictWithAdditionalModelListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalModelListProperties( + dict_property = { + 'key' : [ + petstore_api.models.creature_info.CreatureInfo( + name = '', ) + ] + } + ) + else: + return UnnamedDictWithAdditionalModelListProperties( + ) + """ + + def testUnnamedDictWithAdditionalModelListProperties(self): + """Test UnnamedDictWithAdditionalModelListProperties""" + # 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-aiohttp/test/test_unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..832dc0c32d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_unnamed_dict_with_additional_string_list_properties.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.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalStringListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalStringListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalStringListProperties: + """Test UnnamedDictWithAdditionalStringListProperties + 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 `UnnamedDictWithAdditionalStringListProperties` + """ + model = UnnamedDictWithAdditionalStringListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalStringListProperties( + dict_property = { + 'key' : [ + '' + ] + } + ) + else: + return UnnamedDictWithAdditionalStringListProperties( + ) + """ + + def testUnnamedDictWithAdditionalStringListProperties(self): + """Test UnnamedDictWithAdditionalStringListProperties""" + # 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 b4bc51e0452..00dc818606f 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 @@ -86,6 +86,8 @@ docs/StoreApi.md docs/Tag.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md +docs/UnnamedDictWithAdditionalModelListProperties.md +docs/UnnamedDictWithAdditionalStringListProperties.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -181,6 +183,8 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py +petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +petstore_api/models/unnamed_dict_with_additional_string_list_properties.py petstore_api/models/user.py petstore_api/models/with_nested_one_of.py petstore_api/py.typed 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 72e5fdc62d8..9aa800b4f2b 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -212,6 +212,8 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) + - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) + - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md new file mode 100644 index 00000000000..c102bb86beb --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalModelListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[CreatureInfo]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalModelListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalModelListProperties from a dict +unnamed_dict_with_additional_model_list_properties_form_dict = unnamed_dict_with_additional_model_list_properties.from_dict(unnamed_dict_with_additional_model_list_properties_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/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md new file mode 100644 index 00000000000..926404ccd6e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalStringListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[str]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalStringListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalStringListProperties from a dict +unnamed_dict_with_additional_string_list_properties_form_dict = unnamed_dict_with_additional_string_list_properties.from_dict(unnamed_dict_with_additional_string_list_properties_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 69c88cf7525..c1c56eb8115 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 @@ -115,5 +115,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf 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 a00e5da5310..dd9388d355d 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 @@ -91,5 +91,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..d948e70725f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,88 @@ +# 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, Field, conlist +from petstore_api.models.creature_info import CreatureInfo + +class UnnamedDictWithAdditionalModelListProperties(BaseModel): + """ + UnnamedDictWithAdditionalModelListProperties + """ + dict_property: Optional[Dict[str, conlist(CreatureInfo)]] = Field(None, alias="dictProperty") + __properties = ["dictProperty"] + + 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) -> UnnamedDictWithAdditionalModelListProperties: + """Create an instance of UnnamedDictWithAdditionalModelListProperties 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 value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key]: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> UnnamedDictWithAdditionalModelListProperties: + """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return UnnamedDictWithAdditionalModelListProperties.parse_obj(obj) + + _obj = UnnamedDictWithAdditionalModelListProperties.parse_obj({ + "dict_property": dict( + (_k, + [CreatureInfo.from_dict(_item) for _item in _v] + if _v is not None + else None + ) + for _k, _v in obj.get("dictProperty").items() + ) + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..df1dcd41074 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -0,0 +1,80 @@ +# 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, Field, StrictStr, conlist + +class UnnamedDictWithAdditionalStringListProperties(BaseModel): + """ + UnnamedDictWithAdditionalStringListProperties + """ + dict_property: Optional[Dict[str, conlist(StrictStr)]] = Field(None, alias="dictProperty") + __properties = ["dictProperty"] + + 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) -> UnnamedDictWithAdditionalStringListProperties: + """Create an instance of UnnamedDictWithAdditionalStringListProperties 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 value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key]: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> UnnamedDictWithAdditionalStringListProperties: + """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return UnnamedDictWithAdditionalStringListProperties.parse_obj(obj) + + _obj = UnnamedDictWithAdditionalStringListProperties.parse_obj({ + "dict_property": obj.get("dictProperty") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..64854cb7ee9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,57 @@ +# 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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalModelListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalModelListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalModelListProperties: + """Test UnnamedDictWithAdditionalModelListProperties + 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 `UnnamedDictWithAdditionalModelListProperties` + """ + model = UnnamedDictWithAdditionalModelListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalModelListProperties( + dict_property = { + 'key' : [ + petstore_api.models.creature_info.CreatureInfo( + name = '', ) + ] + } + ) + else: + return UnnamedDictWithAdditionalModelListProperties( + ) + """ + + def testUnnamedDictWithAdditionalModelListProperties(self): + """Test UnnamedDictWithAdditionalModelListProperties""" + # 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/test/test_unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..832dc0c32d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_unnamed_dict_with_additional_string_list_properties.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.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalStringListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalStringListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalStringListProperties: + """Test UnnamedDictWithAdditionalStringListProperties + 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 `UnnamedDictWithAdditionalStringListProperties` + """ + model = UnnamedDictWithAdditionalStringListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalStringListProperties( + dict_property = { + 'key' : [ + '' + ] + } + ) + else: + return UnnamedDictWithAdditionalStringListProperties( + ) + """ + + def testUnnamedDictWithAdditionalStringListProperties(self): + """Test UnnamedDictWithAdditionalStringListProperties""" + # 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 b4bc51e0452..00dc818606f 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -86,6 +86,8 @@ docs/StoreApi.md docs/Tag.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md +docs/UnnamedDictWithAdditionalModelListProperties.md +docs/UnnamedDictWithAdditionalStringListProperties.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -181,6 +183,8 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py +petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +petstore_api/models/unnamed_dict_with_additional_string_list_properties.py petstore_api/models/user.py petstore_api/models/with_nested_one_of.py petstore_api/py.typed diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index b2c701e6894..3628ec73d27 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -212,6 +212,8 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) + - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) + - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/UnnamedDictWithAdditionalModelListProperties.md new file mode 100644 index 00000000000..c102bb86beb --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalModelListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[CreatureInfo]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalModelListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalModelListProperties from a dict +unnamed_dict_with_additional_model_list_properties_form_dict = unnamed_dict_with_additional_model_list_properties.from_dict(unnamed_dict_with_additional_model_list_properties_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/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/UnnamedDictWithAdditionalStringListProperties.md new file mode 100644 index 00000000000..926404ccd6e --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalStringListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[str]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalStringListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalStringListProperties from a dict +unnamed_dict_with_additional_string_list_properties_form_dict = unnamed_dict_with_additional_string_list_properties.from_dict(unnamed_dict_with_additional_string_list_properties_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 69c88cf7525..c1c56eb8115 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 @@ -115,5 +115,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf 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 a00e5da5310..dd9388d355d 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 @@ -91,5 +91,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..be7bbac84d7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,100 @@ +# 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, Field, conlist +from petstore_api.models.creature_info import CreatureInfo + +class UnnamedDictWithAdditionalModelListProperties(BaseModel): + """ + UnnamedDictWithAdditionalModelListProperties + """ + dict_property: Optional[Dict[str, conlist(CreatureInfo)]] = Field(None, alias="dictProperty") + additional_properties: Dict[str, Any] = {} + __properties = ["dictProperty"] + + 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) -> UnnamedDictWithAdditionalModelListProperties: + """Create an instance of UnnamedDictWithAdditionalModelListProperties 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 value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key]: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + # 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) -> UnnamedDictWithAdditionalModelListProperties: + """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return UnnamedDictWithAdditionalModelListProperties.parse_obj(obj) + + _obj = UnnamedDictWithAdditionalModelListProperties.parse_obj({ + "dict_property": dict( + (_k, + [CreatureInfo.from_dict(_item) for _item in _v] + if _v is not None + else None + ) + for _k, _v in obj.get("dictProperty").items() + ) + }) + # 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/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..fa1e5eec56a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -0,0 +1,92 @@ +# 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, Field, StrictStr, conlist + +class UnnamedDictWithAdditionalStringListProperties(BaseModel): + """ + UnnamedDictWithAdditionalStringListProperties + """ + dict_property: Optional[Dict[str, conlist(StrictStr)]] = Field(None, alias="dictProperty") + additional_properties: Dict[str, Any] = {} + __properties = ["dictProperty"] + + 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) -> UnnamedDictWithAdditionalStringListProperties: + """Create an instance of UnnamedDictWithAdditionalStringListProperties 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 value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key]: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + # 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) -> UnnamedDictWithAdditionalStringListProperties: + """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return UnnamedDictWithAdditionalStringListProperties.parse_obj(obj) + + _obj = UnnamedDictWithAdditionalStringListProperties.parse_obj({ + "dict_property": obj.get("dictProperty") + }) + # 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_unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..64854cb7ee9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,57 @@ +# 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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalModelListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalModelListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalModelListProperties: + """Test UnnamedDictWithAdditionalModelListProperties + 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 `UnnamedDictWithAdditionalModelListProperties` + """ + model = UnnamedDictWithAdditionalModelListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalModelListProperties( + dict_property = { + 'key' : [ + petstore_api.models.creature_info.CreatureInfo( + name = '', ) + ] + } + ) + else: + return UnnamedDictWithAdditionalModelListProperties( + ) + """ + + def testUnnamedDictWithAdditionalModelListProperties(self): + """Test UnnamedDictWithAdditionalModelListProperties""" + # 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/test/test_unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..832dc0c32d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_unnamed_dict_with_additional_string_list_properties.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.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalStringListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalStringListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalStringListProperties: + """Test UnnamedDictWithAdditionalStringListProperties + 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 `UnnamedDictWithAdditionalStringListProperties` + """ + model = UnnamedDictWithAdditionalStringListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalStringListProperties( + dict_property = { + 'key' : [ + '' + ] + } + ) + else: + return UnnamedDictWithAdditionalStringListProperties( + ) + """ + + def testUnnamedDictWithAdditionalStringListProperties(self): + """Test UnnamedDictWithAdditionalStringListProperties""" + # 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 a126507222a..ff22e285512 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -86,6 +86,8 @@ docs/StoreApi.md docs/Tag.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md +docs/UnnamedDictWithAdditionalModelListProperties.md +docs/UnnamedDictWithAdditionalStringListProperties.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -181,6 +183,8 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py +petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +petstore_api/models/unnamed_dict_with_additional_string_list_properties.py petstore_api/models/user.py petstore_api/models/with_nested_one_of.py petstore_api/py.typed diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 9cf2313fc92..cf91d3ad0ce 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -212,6 +212,8 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) + - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) + - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md new file mode 100644 index 00000000000..c102bb86beb --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalModelListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[CreatureInfo]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalModelListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalModelListProperties from a dict +unnamed_dict_with_additional_model_list_properties_form_dict = unnamed_dict_with_additional_model_list_properties.from_dict(unnamed_dict_with_additional_model_list_properties_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/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalStringListProperties.md new file mode 100644 index 00000000000..926404ccd6e --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -0,0 +1,28 @@ +# UnnamedDictWithAdditionalStringListProperties + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dict_property** | **Dict[str, List[str]]** | | [optional] + +## Example + +```python +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties + +# TODO update the JSON string below +json = "{}" +# create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +# print the JSON string representation of the object +print UnnamedDictWithAdditionalStringListProperties.to_json() + +# convert the object into a dict +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +# create an instance of UnnamedDictWithAdditionalStringListProperties from a dict +unnamed_dict_with_additional_string_list_properties_form_dict = unnamed_dict_with_additional_string_list_properties.from_dict(unnamed_dict_with_additional_string_list_properties_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 69c88cf7525..c1c56eb8115 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -115,5 +115,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf 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 a00e5da5310..dd9388d355d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -91,5 +91,7 @@ from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger +from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties +from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties from petstore_api.models.user import User from petstore_api.models.with_nested_one_of import WithNestedOneOf diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 3b617a4fbdb..cbc1f669c86 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -78,7 +78,7 @@ class MapOfArrayOfModel(BaseModel): _field_dict_of_array = {} if self.shop_id_to_org_online_lip_map: for _key in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key]: + if self.shop_id_to_org_online_lip_map[_key] is not None: _field_dict_of_array[_key] = [ _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key] ] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..ed29383d86e --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,108 @@ +# 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, ClassVar, Dict, List, Optional +from pydantic import BaseModel +from pydantic import Field +from petstore_api.models.creature_info import CreatureInfo +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class UnnamedDictWithAdditionalModelListProperties(BaseModel): + """ + UnnamedDictWithAdditionalModelListProperties + """ + dict_property: Optional[Dict[str, List[CreatureInfo]]] = Field(default=None, alias="dictProperty") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["dictProperty"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalModelListProperties 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.model_dump(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) + _field_dict_of_array = {} + if self.dict_property: + for _key in self.dict_property: + if self.dict_property[_key] is not None: + _field_dict_of_array[_key] = [ + _item.to_dict() for _item in self.dict_property[_key] + ] + _dict['dictProperty'] = _field_dict_of_array + # 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "dictProperty": dict( + (_k, + [CreatureInfo.from_dict(_item) for _item in _v] + if _v is not None + else None + ) + for _k, _v in obj.get("dictProperty").items() + ) + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..377fbf4abde --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.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, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +from pydantic import Field +from typing import Dict, Any +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class UnnamedDictWithAdditionalStringListProperties(BaseModel): + """ + UnnamedDictWithAdditionalStringListProperties + """ + dict_property: Optional[Dict[str, List[StrictStr]]] = Field(default=None, alias="dictProperty") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["dictProperty"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalStringListProperties 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.model_dump(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # 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) -> Self: + """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "dictProperty": obj.get("dictProperty") + }) + # 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_unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/test/test_unnamed_dict_with_additional_model_list_properties.py new file mode 100644 index 00000000000..64854cb7ee9 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_unnamed_dict_with_additional_model_list_properties.py @@ -0,0 +1,57 @@ +# 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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalModelListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalModelListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalModelListProperties: + """Test UnnamedDictWithAdditionalModelListProperties + 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 `UnnamedDictWithAdditionalModelListProperties` + """ + model = UnnamedDictWithAdditionalModelListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalModelListProperties( + dict_property = { + 'key' : [ + petstore_api.models.creature_info.CreatureInfo( + name = '', ) + ] + } + ) + else: + return UnnamedDictWithAdditionalModelListProperties( + ) + """ + + def testUnnamedDictWithAdditionalModelListProperties(self): + """Test UnnamedDictWithAdditionalModelListProperties""" + # 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/test/test_unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/test/test_unnamed_dict_with_additional_string_list_properties.py new file mode 100644 index 00000000000..832dc0c32d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_unnamed_dict_with_additional_string_list_properties.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.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties # noqa: E501 + +class TestUnnamedDictWithAdditionalStringListProperties(unittest.TestCase): + """UnnamedDictWithAdditionalStringListProperties unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> UnnamedDictWithAdditionalStringListProperties: + """Test UnnamedDictWithAdditionalStringListProperties + 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 `UnnamedDictWithAdditionalStringListProperties` + """ + model = UnnamedDictWithAdditionalStringListProperties() # noqa: E501 + if include_optional: + return UnnamedDictWithAdditionalStringListProperties( + dict_property = { + 'key' : [ + '' + ] + } + ) + else: + return UnnamedDictWithAdditionalStringListProperties( + ) + """ + + def testUnnamedDictWithAdditionalStringListProperties(self): + """Test UnnamedDictWithAdditionalStringListProperties""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 49ac980c1be..c41bfe8e753 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -587,3 +587,30 @@ class ModelTests(unittest.TestCase): a3.additional_properties = { "xyz": 45.6 } self.assertEqual(a3.to_dict(), {"xyz": 45.6}) self.assertEqual(a3.to_json(), '{"xyz": 45.6}') + +class TestUnnamedDictWithAdditionalStringListProperties: + def test_empty_dict(self): + a = petstore_api.UnnamedDictWithAdditionalStringListProperties(dict_property={}) + assert a.to_dict() == {"dictProperty": {}} + + def test_empty_list(self): + a = petstore_api.UnnamedDictWithAdditionalStringListProperties(dict_property={"b": []}) + assert a.to_dict() == {"dictProperty": {"b": []}} + + def test_single_string_item(self): + a = petstore_api.UnnamedDictWithAdditionalStringListProperties(dict_property={"b": ["c"]}) + assert a.to_dict() == {"dictProperty": {"b": ["c"]}} + +class TestUnnamedDictWithAdditionalModelListProperties: + def test_empty_dict(self): + a = petstore_api.UnnamedDictWithAdditionalModelListProperties(dict_property={}) + assert a.to_dict() == {"dictProperty": {}} + + def test_empty_list(self): + a = petstore_api.UnnamedDictWithAdditionalModelListProperties(dict_property={"b": []}) + assert a.to_dict() == {"dictProperty": {"b": []}} + + def test_single_string_item(self): + value = {"b": [petstore_api.CreatureInfo(name="creature_name")]} + a = petstore_api.UnnamedDictWithAdditionalModelListProperties(dict_property=value) + assert a.to_dict() == {"dictProperty": {"b": [{"name": "creature_name"}]}}