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 0a1d4d5cfad..4b16bbcff1c 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 @@ -2246,3 +2246,30 @@ components: description: Property type: boolean default: false + Creature: + type: object + required: + - info + - type + properties: + info: + $ref: "#/components/schemas/CreatureInfo" + type: + type: string + discriminator: + propertyName: type + CreatureInfo: + type: object + required: + - name + properties: + name: + type: string + Tiger: + allOf: + - $ref: "#/components/schemas/Tiger" + - type: object + properties: + skill: + type: string + diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index c1ffcecbc45..a30ce812a9a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -22,6 +22,8 @@ docs/CircularReferenceModel.md docs/ClassModel.md docs/Client.md docs/Color.md +docs/Creature.md +docs/CreatureInfo.md docs/DanishPig.md docs/DefaultApi.md docs/DeprecatedObject.md @@ -79,6 +81,7 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Tiger.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -115,6 +118,8 @@ petstore_api/models/circular_reference_model.py petstore_api/models/class_model.py petstore_api/models/client.py petstore_api/models/color.py +petstore_api/models/creature.py +petstore_api/models/creature_info.py petstore_api/models/danish_pig.py petstore_api/models/deprecated_object.py petstore_api/models/dog.py @@ -167,6 +172,7 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/tiger.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 5732dbce4aa..a443818bd2f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -150,6 +150,8 @@ Class | Method | HTTP request | Description - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [Color](docs/Color.md) + - [Creature](docs/Creature.md) + - [CreatureInfo](docs/CreatureInfo.md) - [DanishPig](docs/DanishPig.md) - [DeprecatedObject](docs/DeprecatedObject.md) - [Dog](docs/Dog.md) @@ -202,6 +204,7 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Tiger](docs/Tiger.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md new file mode 100644 index 00000000000..54249d5871e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md @@ -0,0 +1,29 @@ +# Creature + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**info** | [**CreatureInfo**](CreatureInfo.md) | | +**type** | **str** | | + +## Example + +```python +from petstore_api.models.creature import Creature + +# TODO update the JSON string below +json = "{}" +# create an instance of Creature from a JSON string +creature_instance = Creature.from_json(json) +# print the JSON string representation of the object +print Creature.to_json() + +# convert the object into a dict +creature_dict = creature_instance.to_dict() +# create an instance of Creature from a dict +creature_form_dict = creature.from_dict(creature_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/CreatureInfo.md b/samples/openapi3/client/petstore/python-aiohttp/docs/CreatureInfo.md new file mode 100644 index 00000000000..5a600b9f337 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/CreatureInfo.md @@ -0,0 +1,28 @@ +# CreatureInfo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | + +## Example + +```python +from petstore_api.models.creature_info import CreatureInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of CreatureInfo from a JSON string +creature_info_instance = CreatureInfo.from_json(json) +# print the JSON string representation of the object +print CreatureInfo.to_json() + +# convert the object into a dict +creature_info_dict = creature_info_instance.to_dict() +# create an instance of CreatureInfo from a dict +creature_info_form_dict = creature_info.from_dict(creature_info_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/Tiger.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Tiger.md new file mode 100644 index 00000000000..6ce50a31f5a --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Tiger.md @@ -0,0 +1,28 @@ +# Tiger + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**skill** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.tiger import Tiger + +# TODO update the JSON string below +json = "{}" +# create an instance of Tiger from a JSON string +tiger_instance = Tiger.from_json(json) +# print the JSON string representation of the object +print Tiger.to_json() + +# convert the object into a dict +tiger_dict = tiger_instance.to_dict() +# create an instance of Tiger from a dict +tiger_form_dict = tiger.from_dict(tiger_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 7ee83df43a5..65b7d10c97b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -56,6 +56,8 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo from petstore_api.models.danish_pig import DanishPig from petstore_api.models.deprecated_object import DeprecatedObject from petstore_api.models.dog import Dog @@ -108,5 +110,6 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger 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 d88d6edde7d..144361528d0 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 @@ -32,6 +32,8 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo from petstore_api.models.danish_pig import DanishPig from petstore_api.models.deprecated_object import DeprecatedObject from petstore_api.models.dog import Dog @@ -84,5 +86,6 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger 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/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py new file mode 100644 index 00000000000..f7f65d3555d --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.creature_info import CreatureInfo + +class Creature(BaseModel): + """ + Creature + """ + info: CreatureInfo = Field(...) + type: StrictStr = Field(...) + __properties = ["info", "type"] + + 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) -> Creature: + """Create an instance of Creature 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 info + if self.info: + _dict['info'] = self.info.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Creature: + """Create an instance of Creature from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Creature.parse_obj(obj) + + _obj = Creature.parse_obj({ + "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, + "type": obj.get("type") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py new file mode 100644 index 00000000000..d17f4975e42 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + +from pydantic import BaseModel, Field, StrictStr + +class CreatureInfo(BaseModel): + """ + CreatureInfo + """ + name: StrictStr = Field(...) + __properties = ["name"] + + 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) -> CreatureInfo: + """Create an instance of CreatureInfo 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) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> CreatureInfo: + """Create an instance of CreatureInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return CreatureInfo.parse_obj(obj) + + _obj = CreatureInfo.parse_obj({ + "name": obj.get("name") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py new file mode 100644 index 00000000000..8d619d30694 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic import BaseModel, StrictStr + +class Tiger(BaseModel): + """ + Tiger + """ + skill: Optional[StrictStr] = None + __properties = ["skill"] + + 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) -> Tiger: + """Create an instance of Tiger 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) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Tiger: + """Create an instance of Tiger from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Tiger.parse_obj(obj) + + _obj = Tiger.parse_obj({ + "skill": obj.get("skill") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_creature.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_creature.py new file mode 100644 index 00000000000..66b3e088cbb --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_creature.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature import Creature # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreature(unittest.TestCase): + """Creature unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Creature + 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 `Creature` + """ + model = petstore_api.models.creature.Creature() # noqa: E501 + if include_optional : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '' + ) + else : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '', + ) + """ + + def testCreature(self): + """Test Creature""" + # 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_creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_creature_info.py new file mode 100644 index 00000000000..0a85d5ffe7b --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_creature_info.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: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature_info import CreatureInfo # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreatureInfo(unittest.TestCase): + """CreatureInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test CreatureInfo + 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 `CreatureInfo` + """ + model = petstore_api.models.creature_info.CreatureInfo() # noqa: E501 + if include_optional : + return CreatureInfo( + name = '' + ) + else : + return CreatureInfo( + name = '', + ) + """ + + def testCreatureInfo(self): + """Test CreatureInfo""" + # 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_tiger.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_tiger.py new file mode 100644 index 00000000000..83c91cea1a0 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_tiger.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.tiger import Tiger # noqa: E501 +from petstore_api.rest import ApiException + +class TestTiger(unittest.TestCase): + """Tiger unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Tiger + 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 `Tiger` + """ + model = petstore_api.models.tiger.Tiger() # noqa: E501 + if include_optional : + return Tiger( + skill = '' + ) + else : + return Tiger( + ) + """ + + def testTiger(self): + """Test Tiger""" + # 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 56fbf32a07e..370c0480ea2 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -22,6 +22,8 @@ docs/CircularReferenceModel.md docs/ClassModel.md docs/Client.md docs/Color.md +docs/Creature.md +docs/CreatureInfo.md docs/DanishPig.md docs/DefaultApi.md docs/DeprecatedObject.md @@ -79,6 +81,7 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Tiger.md docs/User.md docs/UserApi.md docs/WithNestedOneOf.md @@ -115,6 +118,8 @@ petstore_api/models/circular_reference_model.py petstore_api/models/class_model.py petstore_api/models/client.py petstore_api/models/color.py +petstore_api/models/creature.py +petstore_api/models/creature_info.py petstore_api/models/danish_pig.py petstore_api/models/deprecated_object.py petstore_api/models/dog.py @@ -167,6 +172,7 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/tiger.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 449912d5c09..534b6c8135a 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -150,6 +150,8 @@ Class | Method | HTTP request | Description - [ClassModel](docs/ClassModel.md) - [Client](docs/Client.md) - [Color](docs/Color.md) + - [Creature](docs/Creature.md) + - [CreatureInfo](docs/CreatureInfo.md) - [DanishPig](docs/DanishPig.md) - [DeprecatedObject](docs/DeprecatedObject.md) - [Dog](docs/Dog.md) @@ -202,6 +204,7 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Tiger](docs/Tiger.md) - [User](docs/User.md) - [WithNestedOneOf](docs/WithNestedOneOf.md) diff --git a/samples/openapi3/client/petstore/python/docs/Creature.md b/samples/openapi3/client/petstore/python/docs/Creature.md new file mode 100644 index 00000000000..54249d5871e --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Creature.md @@ -0,0 +1,29 @@ +# Creature + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**info** | [**CreatureInfo**](CreatureInfo.md) | | +**type** | **str** | | + +## Example + +```python +from petstore_api.models.creature import Creature + +# TODO update the JSON string below +json = "{}" +# create an instance of Creature from a JSON string +creature_instance = Creature.from_json(json) +# print the JSON string representation of the object +print Creature.to_json() + +# convert the object into a dict +creature_dict = creature_instance.to_dict() +# create an instance of Creature from a dict +creature_form_dict = creature.from_dict(creature_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/CreatureInfo.md b/samples/openapi3/client/petstore/python/docs/CreatureInfo.md new file mode 100644 index 00000000000..5a600b9f337 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/CreatureInfo.md @@ -0,0 +1,28 @@ +# CreatureInfo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | + +## Example + +```python +from petstore_api.models.creature_info import CreatureInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of CreatureInfo from a JSON string +creature_info_instance = CreatureInfo.from_json(json) +# print the JSON string representation of the object +print CreatureInfo.to_json() + +# convert the object into a dict +creature_info_dict = creature_info_instance.to_dict() +# create an instance of CreatureInfo from a dict +creature_info_form_dict = creature_info.from_dict(creature_info_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/Tiger.md b/samples/openapi3/client/petstore/python/docs/Tiger.md new file mode 100644 index 00000000000..6ce50a31f5a --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Tiger.md @@ -0,0 +1,28 @@ +# Tiger + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**skill** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.tiger import Tiger + +# TODO update the JSON string below +json = "{}" +# create an instance of Tiger from a JSON string +tiger_instance = Tiger.from_json(json) +# print the JSON string representation of the object +print Tiger.to_json() + +# convert the object into a dict +tiger_dict = tiger_instance.to_dict() +# create an instance of Tiger from a dict +tiger_form_dict = tiger.from_dict(tiger_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 7ee83df43a5..65b7d10c97b 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -56,6 +56,8 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo from petstore_api.models.danish_pig import DanishPig from petstore_api.models.deprecated_object import DeprecatedObject from petstore_api.models.dog import Dog @@ -108,5 +110,6 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger 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 d88d6edde7d..144361528d0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -32,6 +32,8 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client from petstore_api.models.color import Color +from petstore_api.models.creature import Creature +from petstore_api.models.creature_info import CreatureInfo from petstore_api.models.danish_pig import DanishPig from petstore_api.models.deprecated_object import DeprecatedObject from petstore_api.models.dog import Dog @@ -84,5 +86,6 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.tiger import Tiger 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/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py new file mode 100644 index 00000000000..b672dd71bab --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.creature_info import CreatureInfo + +class Creature(BaseModel): + """ + Creature + """ + info: CreatureInfo = Field(...) + type: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["info", "type"] + + 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) -> Creature: + """Create an instance of Creature 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 info + if self.info: + _dict['info'] = self.info.to_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(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Creature: + """Create an instance of Creature from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Creature.parse_obj(obj) + + _obj = Creature.parse_obj({ + "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, + "type": obj.get("type") + }) + # 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/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py new file mode 100644 index 00000000000..8d4421bee15 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr + +class CreatureInfo(BaseModel): + """ + CreatureInfo + """ + name: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["name"] + + 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) -> CreatureInfo: + """Create an instance of CreatureInfo 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) + # 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) -> CreatureInfo: + """Create an instance of CreatureInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return CreatureInfo.parse_obj(obj) + + _obj = CreatureInfo.parse_obj({ + "name": obj.get("name") + }) + # 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/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py new file mode 100644 index 00000000000..215248c2d71 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class Tiger(BaseModel): + """ + Tiger + """ + skill: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["skill"] + + 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) -> Tiger: + """Create an instance of Tiger 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) + # 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) -> Tiger: + """Create an instance of Tiger from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Tiger.parse_obj(obj) + + _obj = Tiger.parse_obj({ + "skill": obj.get("skill") + }) + # 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_creature.py b/samples/openapi3/client/petstore/python/test/test_creature.py new file mode 100644 index 00000000000..66b3e088cbb --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_creature.py @@ -0,0 +1,59 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature import Creature # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreature(unittest.TestCase): + """Creature unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Creature + 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 `Creature` + """ + model = petstore_api.models.creature.Creature() # noqa: E501 + if include_optional : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '' + ) + else : + return Creature( + info = petstore_api.models.creature_info.CreatureInfo( + name = '', ), + type = '', + ) + """ + + def testCreature(self): + """Test Creature""" + # 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_creature_info.py b/samples/openapi3/client/petstore/python/test/test_creature_info.py new file mode 100644 index 00000000000..0a85d5ffe7b --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_creature_info.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: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.creature_info import CreatureInfo # noqa: E501 +from petstore_api.rest import ApiException + +class TestCreatureInfo(unittest.TestCase): + """CreatureInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test CreatureInfo + 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 `CreatureInfo` + """ + model = petstore_api.models.creature_info.CreatureInfo() # noqa: E501 + if include_optional : + return CreatureInfo( + name = '' + ) + else : + return CreatureInfo( + name = '', + ) + """ + + def testCreatureInfo(self): + """Test CreatureInfo""" + # 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_tiger.py b/samples/openapi3/client/petstore/python/test/test_tiger.py new file mode 100644 index 00000000000..83c91cea1a0 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_tiger.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" + + +import unittest +import datetime + +import petstore_api +from petstore_api.models.tiger import Tiger # noqa: E501 +from petstore_api.rest import ApiException + +class TestTiger(unittest.TestCase): + """Tiger unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test Tiger + 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 `Tiger` + """ + model = petstore_api.models.tiger.Tiger() # noqa: E501 + if include_optional : + return Tiger( + skill = '' + ) + else : + return Tiger( + ) + """ + + def testTiger(self): + """Test Tiger""" + # 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 7cbe124bfc4..7032ed8893e 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -513,3 +513,10 @@ class ModelTests(unittest.TestCase): a = petstore_api.FirstRef.from_dict({}) self.assertEqual(a.to_json(), "{}") + def test_allof(self): + # for issue 16104 + model = petstore_api.Tiger.from_json('{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + # shouldn't throw NameError + self.assertEqual(model.to_json(), '{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + +