From 4cfc8eff003e7d97c99fa051248e1c75b6f0dd95 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 4 Jun 2025 16:18:10 +0800 Subject: [PATCH] Add tests for enum names with dots in python cilents (#21374) * add tests for enum names with dot * remove file * apply same fix to python pydantic v1 * update test --- .../AbstractPythonPydanticV1Codegen.java | 2 + .../src/test/resources/3_0/enum_float.yaml | 33 ------ ...ith-fake-endpoints-models-for-testing.yaml | 12 +++ .../python-aiohttp/.openapi-generator/FILES | 4 + .../client/petstore/python-aiohttp/README.md | 2 + .../petstore/python-aiohttp/docs/PonySizes.md | 29 +++++ .../petstore/python-aiohttp/docs/Type.md | 16 +++ .../python-aiohttp/petstore_api/__init__.py | 4 + .../petstore_api/models/__init__.py | 2 + .../petstore_api/models/pony_sizes.py | 88 +++++++++++++++ .../petstore_api/models/type.py | 39 +++++++ .../python-aiohttp/test/test_pony_sizes.py | 51 +++++++++ .../petstore/python-aiohttp/test/test_type.py | 33 ++++++ .../.openapi-generator/FILES | 4 + .../python-pydantic-v1-aiohttp/README.md | 2 + .../docs/PonySizes.md | 28 +++++ .../python-pydantic-v1-aiohttp/docs/Type.md | 16 +++ .../petstore_api/__init__.py | 4 + .../petstore_api/models/__init__.py | 2 + .../petstore_api/models/pony_sizes.py | 72 +++++++++++++ .../petstore_api/models/type.py | 42 ++++++++ .../test/test_pony_sizes.py | 52 +++++++++ .../test/test_type.py | 34 ++++++ .../.openapi-generator/FILES | 4 + .../petstore/python-pydantic-v1/README.md | 2 + .../python-pydantic-v1/docs/PonySizes.md | 28 +++++ .../petstore/python-pydantic-v1/docs/Type.md | 16 +++ .../petstore_api/__init__.py | 4 + .../petstore_api/models/__init__.py | 2 + .../petstore_api/models/pony_sizes.py | 84 +++++++++++++++ .../petstore_api/models/type.py | 42 ++++++++ .../test/test_pony_sizes.py | 52 +++++++++ .../python-pydantic-v1/test/test_type.py | 34 ++++++ .../petstore/python/.openapi-generator/FILES | 4 + .../openapi3/client/petstore/python/README.md | 2 + .../client/petstore/python/docs/PonySizes.md | 29 +++++ .../client/petstore/python/docs/Type.md | 16 +++ .../petstore/python/petstore_api/__init__.py | 4 + .../python/petstore_api/models/__init__.py | 2 + .../python/petstore_api/models/pony_sizes.py | 101 ++++++++++++++++++ .../python/petstore_api/models/type.py | 39 +++++++ .../petstore/python/test/test_pony_sizes.py | 51 +++++++++ .../client/petstore/python/test/test_type.py | 33 ++++++ 43 files changed, 1087 insertions(+), 33 deletions(-) delete mode 100644 modules/openapi-generator/src/test/resources/3_0/enum_float.yaml create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/Type.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_type.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PonySizes.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Type.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/type.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_type.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/PonySizes.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/Type.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/type.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_type.py create mode 100644 samples/openapi3/client/petstore/python/docs/PonySizes.md create mode 100644 samples/openapi3/client/petstore/python/docs/Type.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/type.py create mode 100644 samples/openapi3/client/petstore/python/test/test_pony_sizes.py create mode 100644 samples/openapi3/client/petstore/python/test/test_type.py diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java index 52f370673bf..da8434e1ae3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java @@ -1593,6 +1593,8 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp } public String toEnumVariableName(String name, String datatype) { + name = name.replace(".", "_DOT_"); + if ("int".equals(datatype)) { return "NUMBER_" + name.replace("-", "MINUS_"); } diff --git a/modules/openapi-generator/src/test/resources/3_0/enum_float.yaml b/modules/openapi-generator/src/test/resources/3_0/enum_float.yaml deleted file mode 100644 index 909521c8c61..00000000000 --- a/modules/openapi-generator/src/test/resources/3_0/enum_float.yaml +++ /dev/null @@ -1,33 +0,0 @@ -openapi: 3.0.0 -info: - title: Sample API - description: API description in Markdown. - version: 1.0.0 -paths: - /pony-sizes: - get: - summary: Returns all pony sizes. - description: Optional extended description in Markdown. - responses: - 200: - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/PonySizes' -components: - schemas: - PonySizes: - type: object - properties: - type: - $ref: '#/components/schemas/Type' - Type: - type: float - enum: - - 2.0 - - 1.0 - - 0.5 - - 0.25 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 91d4133352e..e1c1388f3df 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 @@ -2898,3 +2898,15 @@ components: - B - C default: B + PonySizes: + type: object + properties: + type: + $ref: '#/components/schemas/Type' + Type: + type: float + enum: + - 2.0 + - 1.0 + - 0.5 + - 0.25 diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index e9cb10689de..97c491419a4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PonySizes.md docs/PoopCleaning.md docs/PrimitiveString.md docs/PropertyMap.md @@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md +docs/Type.md docs/UnnamedDictWithAdditionalModelListProperties.md docs/UnnamedDictWithAdditionalStringListProperties.md docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -215,6 +217,7 @@ petstore_api/models/parent.py petstore_api/models/parent_with_optional_dict.py petstore_api/models/pet.py petstore_api/models/pig.py +petstore_api/models/pony_sizes.py petstore_api/models/poop_cleaning.py petstore_api/models/primitive_string.py petstore_api/models/property_map.py @@ -238,6 +241,7 @@ petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/test_model_with_enum_default.py petstore_api/models/test_object_for_multipart_requests_request_marker.py petstore_api/models/tiger.py +petstore_api/models/type.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/upload_file_with_additional_properties_request_object.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 604b6488659..6a34463df56 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -231,6 +231,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PonySizes](docs/PonySizes.md) - [PoopCleaning](docs/PoopCleaning.md) - [PrimitiveString](docs/PrimitiveString.md) - [PropertyMap](docs/PropertyMap.md) @@ -254,6 +255,7 @@ Class | Method | HTTP request | Description - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) + - [Type](docs/Type.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md new file mode 100644 index 00000000000..ced44c87206 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md @@ -0,0 +1,29 @@ +# PonySizes + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | [**Type**](Type.md) | | [optional] + +## Example + +```python +from petstore_api.models.pony_sizes import PonySizes + +# TODO update the JSON string below +json = "{}" +# create an instance of PonySizes from a JSON string +pony_sizes_instance = PonySizes.from_json(json) +# print the JSON string representation of the object +print(PonySizes.to_json()) + +# convert the object into a dict +pony_sizes_dict = pony_sizes_instance.to_dict() +# create an instance of PonySizes from a dict +pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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/Type.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md new file mode 100644 index 00000000000..f7ff2903a72 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Type.md @@ -0,0 +1,16 @@ +# Type + + +## Enum + +* `NUMBER_2_DOT_0` (value: `2.0`) + +* `NUMBER_1_DOT_0` (value: `1.0`) + +* `NUMBER_0_DOT_5` (value: `0.5`) + +* `NUMBER_0_DOT_25` (value: `0.25`) + +[[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 50788f3e21c..21f88b7adb3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -116,6 +116,7 @@ __all__ = [ "ParentWithOptionalDict", "Pet", "Pig", + "PonySizes", "PoopCleaning", "PrimitiveString", "PropertyMap", @@ -139,6 +140,7 @@ __all__ = [ "TestModelWithEnumDefault", "TestObjectForMultipartRequestsRequestMarker", "Tiger", + "Type", "UnnamedDictWithAdditionalModelListProperties", "UnnamedDictWithAdditionalStringListProperties", "UploadFileWithAdditionalPropertiesRequestObject", @@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict from petstore_api.models.pet import Pet as Pet from petstore_api.models.pig import Pig as Pig +from petstore_api.models.pony_sizes import PonySizes as PonySizes from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString from petstore_api.models.property_map import PropertyMap as PropertyMap @@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger as Tiger +from petstore_api.models.type import Type as Type from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject 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 fc1f4acbdaf..c9dd877ed2a 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 @@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict from petstore_api.models.pet import Pet from petstore_api.models.pig import Pig +from petstore_api.models.pony_sizes import PonySizes from petstore_api.models.poop_cleaning import PoopCleaning from petstore_api.models.primitive_string import PrimitiveString from petstore_api.models.property_map import PropertyMap @@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger +from petstore_api.models.type import Type 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.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py new file mode 100644 index 00000000000..00bd3865957 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.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 pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.type import Type +from typing import Optional, Set +from typing_extensions import Self + +class PonySizes(BaseModel): + """ + PonySizes + """ # noqa: E501 + type: Optional[Type] = None + __properties: ClassVar[List[str]] = ["type"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PonySizes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PonySizes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py new file mode 100644 index 00000000000..35a847de894 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/type.py @@ -0,0 +1,39 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class Type(int, Enum): + """ + Type + """ + + """ + allowed enum values + """ + NUMBER_2_DOT_0 = 2.0 + NUMBER_1_DOT_0 = 1.0 + NUMBER_0_DOT_5 = 0.5 + NUMBER_0_DOT_25 = 0.25 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Type from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_pony_sizes.py new file mode 100644 index 00000000000..8586169f798 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_pony_sizes.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.pony_sizes import PonySizes + +class TestPonySizes(unittest.TestCase): + """PonySizes unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PonySizes: + """Test PonySizes + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PonySizes` + """ + model = PonySizes() + if include_optional: + return PonySizes( + type = 2.0 + ) + else: + return PonySizes( + ) + """ + + def testPonySizes(self): + """Test PonySizes""" + # 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_type.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_type.py new file mode 100644 index 00000000000..ecafff8199d --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_type.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.type import Type + +class TestType(unittest.TestCase): + """Type unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testType(self): + """Test Type""" + # inst = Type() + +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 2e28d350da1..8fcd0acf7a1 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 @@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PonySizes.md docs/PoopCleaning.md docs/PrimitiveString.md docs/PropertyMap.md @@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md +docs/Type.md docs/UnnamedDictWithAdditionalModelListProperties.md docs/UnnamedDictWithAdditionalStringListProperties.md docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -215,6 +217,7 @@ petstore_api/models/parent.py petstore_api/models/parent_with_optional_dict.py petstore_api/models/pet.py petstore_api/models/pig.py +petstore_api/models/pony_sizes.py petstore_api/models/poop_cleaning.py petstore_api/models/primitive_string.py petstore_api/models/property_map.py @@ -238,6 +241,7 @@ petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/test_model_with_enum_default.py petstore_api/models/test_object_for_multipart_requests_request_marker.py petstore_api/models/tiger.py +petstore_api/models/type.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/upload_file_with_additional_properties_request_object.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md index 61ef8074074..350d0ca3afc 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -232,6 +232,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PonySizes](docs/PonySizes.md) - [PoopCleaning](docs/PoopCleaning.md) - [PrimitiveString](docs/PrimitiveString.md) - [PropertyMap](docs/PropertyMap.md) @@ -255,6 +256,7 @@ Class | Method | HTTP request | Description - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) + - [Type](docs/Type.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PonySizes.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PonySizes.md new file mode 100644 index 00000000000..6abdccaf3a7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PonySizes.md @@ -0,0 +1,28 @@ +# PonySizes + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | [**Type**](Type.md) | | [optional] + +## Example + +```python +from petstore_api.models.pony_sizes import PonySizes + +# TODO update the JSON string below +json = "{}" +# create an instance of PonySizes from a JSON string +pony_sizes_instance = PonySizes.from_json(json) +# print the JSON string representation of the object +print PonySizes.to_json() + +# convert the object into a dict +pony_sizes_dict = pony_sizes_instance.to_dict() +# create an instance of PonySizes from a dict +pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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/Type.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Type.md new file mode 100644 index 00000000000..f7ff2903a72 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Type.md @@ -0,0 +1,16 @@ +# Type + + +## Enum + +* `NUMBER_2_DOT_0` (value: `2.0`) + +* `NUMBER_1_DOT_0` (value: `1.0`) + +* `NUMBER_0_DOT_5` (value: `0.5`) + +* `NUMBER_0_DOT_25` (value: `0.25`) + +[[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 450799b5e55..343757e2f37 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 @@ -116,6 +116,7 @@ __all__ = [ "ParentWithOptionalDict", "Pet", "Pig", + "PonySizes", "PoopCleaning", "PrimitiveString", "PropertyMap", @@ -139,6 +140,7 @@ __all__ = [ "TestModelWithEnumDefault", "TestObjectForMultipartRequestsRequestMarker", "Tiger", + "Type", "UnnamedDictWithAdditionalModelListProperties", "UnnamedDictWithAdditionalStringListProperties", "UploadFileWithAdditionalPropertiesRequestObject", @@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict from petstore_api.models.pet import Pet as Pet from petstore_api.models.pig import Pig as Pig +from petstore_api.models.pony_sizes import PonySizes as PonySizes from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString from petstore_api.models.property_map import PropertyMap as PropertyMap @@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger as Tiger +from petstore_api.models.type import Type as Type from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject 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 91f0aad8026..8244d762595 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 @@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict from petstore_api.models.pet import Pet from petstore_api.models.pig import Pig +from petstore_api.models.pony_sizes import PonySizes from petstore_api.models.poop_cleaning import PoopCleaning from petstore_api.models.primitive_string import PrimitiveString from petstore_api.models.property_map import PropertyMap @@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger +from petstore_api.models.type import Type 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.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/pony_sizes.py new file mode 100644 index 00000000000..d7c0716b43d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/pony_sizes.py @@ -0,0 +1,72 @@ +# 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 Optional +from pydantic import BaseModel +from petstore_api.models.type import Type + +class PonySizes(BaseModel): + """ + PonySizes + """ + type: Optional[Type] = None + __properties = ["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) -> PonySizes: + """Create an instance of PonySizes 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) -> PonySizes: + """Create an instance of PonySizes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PonySizes.parse_obj(obj) + + _obj = PonySizes.parse_obj({ + "type": obj.get("type") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/type.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/type.py new file mode 100644 index 00000000000..6cfa8b4bf30 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/type.py @@ -0,0 +1,42 @@ +# 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 json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class Type(int, Enum): + """ + Type + """ + + """ + allowed enum values + """ + NUMBER_2_DOT_0 = 2.0 + NUMBER_1_DOT_0 = 1.0 + NUMBER_0_DOT_5 = 0.5 + NUMBER_0_DOT_25 = 0.25 + + @classmethod + def from_json(cls, json_str: str) -> Type: + """Create an instance of Type from a JSON string""" + return Type(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_pony_sizes.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_pony_sizes.py new file mode 100644 index 00000000000..69af8a41f58 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_pony_sizes.py @@ -0,0 +1,52 @@ +# 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.pony_sizes import PonySizes # noqa: E501 + +class TestPonySizes(unittest.TestCase): + """PonySizes unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PonySizes: + """Test PonySizes + 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 `PonySizes` + """ + model = PonySizes() # noqa: E501 + if include_optional: + return PonySizes( + type = 2.0 + ) + else: + return PonySizes( + ) + """ + + def testPonySizes(self): + """Test PonySizes""" + # 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_type.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_type.py new file mode 100644 index 00000000000..9738be707f2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_type.py @@ -0,0 +1,34 @@ +# 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.type import Type # noqa: E501 + +class TestType(unittest.TestCase): + """Type unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testType(self): + """Test Type""" + # inst = Type() + +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 2e28d350da1..8fcd0acf7a1 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PonySizes.md docs/PoopCleaning.md docs/PrimitiveString.md docs/PropertyMap.md @@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md +docs/Type.md docs/UnnamedDictWithAdditionalModelListProperties.md docs/UnnamedDictWithAdditionalStringListProperties.md docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -215,6 +217,7 @@ petstore_api/models/parent.py petstore_api/models/parent_with_optional_dict.py petstore_api/models/pet.py petstore_api/models/pig.py +petstore_api/models/pony_sizes.py petstore_api/models/poop_cleaning.py petstore_api/models/primitive_string.py petstore_api/models/property_map.py @@ -238,6 +241,7 @@ petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/test_model_with_enum_default.py petstore_api/models/test_object_for_multipart_requests_request_marker.py petstore_api/models/tiger.py +petstore_api/models/type.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/upload_file_with_additional_properties_request_object.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 90e3cd59ee6..8f4277c9986 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -232,6 +232,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PonySizes](docs/PonySizes.md) - [PoopCleaning](docs/PoopCleaning.md) - [PrimitiveString](docs/PrimitiveString.md) - [PropertyMap](docs/PropertyMap.md) @@ -255,6 +256,7 @@ Class | Method | HTTP request | Description - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) + - [Type](docs/Type.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/PonySizes.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/PonySizes.md new file mode 100644 index 00000000000..6abdccaf3a7 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/PonySizes.md @@ -0,0 +1,28 @@ +# PonySizes + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | [**Type**](Type.md) | | [optional] + +## Example + +```python +from petstore_api.models.pony_sizes import PonySizes + +# TODO update the JSON string below +json = "{}" +# create an instance of PonySizes from a JSON string +pony_sizes_instance = PonySizes.from_json(json) +# print the JSON string representation of the object +print PonySizes.to_json() + +# convert the object into a dict +pony_sizes_dict = pony_sizes_instance.to_dict() +# create an instance of PonySizes from a dict +pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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/Type.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Type.md new file mode 100644 index 00000000000..f7ff2903a72 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Type.md @@ -0,0 +1,16 @@ +# Type + + +## Enum + +* `NUMBER_2_DOT_0` (value: `2.0`) + +* `NUMBER_1_DOT_0` (value: `1.0`) + +* `NUMBER_0_DOT_5` (value: `0.5`) + +* `NUMBER_0_DOT_25` (value: `0.25`) + +[[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 450799b5e55..343757e2f37 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 @@ -116,6 +116,7 @@ __all__ = [ "ParentWithOptionalDict", "Pet", "Pig", + "PonySizes", "PoopCleaning", "PrimitiveString", "PropertyMap", @@ -139,6 +140,7 @@ __all__ = [ "TestModelWithEnumDefault", "TestObjectForMultipartRequestsRequestMarker", "Tiger", + "Type", "UnnamedDictWithAdditionalModelListProperties", "UnnamedDictWithAdditionalStringListProperties", "UploadFileWithAdditionalPropertiesRequestObject", @@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict from petstore_api.models.pet import Pet as Pet from petstore_api.models.pig import Pig as Pig +from petstore_api.models.pony_sizes import PonySizes as PonySizes from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString from petstore_api.models.property_map import PropertyMap as PropertyMap @@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger as Tiger +from petstore_api.models.type import Type as Type from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject 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 91f0aad8026..8244d762595 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 @@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict from petstore_api.models.pet import Pet from petstore_api.models.pig import Pig +from petstore_api.models.pony_sizes import PonySizes from petstore_api.models.poop_cleaning import PoopCleaning from petstore_api.models.primitive_string import PrimitiveString from petstore_api.models.property_map import PropertyMap @@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger +from petstore_api.models.type import Type 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.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/pony_sizes.py new file mode 100644 index 00000000000..2d04b866cb1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/pony_sizes.py @@ -0,0 +1,84 @@ +# 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, Optional +from pydantic import BaseModel +from petstore_api.models.type import Type + +class PonySizes(BaseModel): + """ + PonySizes + """ + type: Optional[Type] = None + additional_properties: Dict[str, Any] = {} + __properties = ["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) -> PonySizes: + """Create an instance of PonySizes 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) -> PonySizes: + """Create an instance of PonySizes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PonySizes.parse_obj(obj) + + _obj = PonySizes.parse_obj({ + "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-pydantic-v1/petstore_api/models/type.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/type.py new file mode 100644 index 00000000000..6cfa8b4bf30 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/type.py @@ -0,0 +1,42 @@ +# 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 json +import pprint +import re # noqa: F401 +from aenum import Enum, no_arg + + + + + +class Type(int, Enum): + """ + Type + """ + + """ + allowed enum values + """ + NUMBER_2_DOT_0 = 2.0 + NUMBER_1_DOT_0 = 1.0 + NUMBER_0_DOT_5 = 0.5 + NUMBER_0_DOT_25 = 0.25 + + @classmethod + def from_json(cls, json_str: str) -> Type: + """Create an instance of Type from a JSON string""" + return Type(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_pony_sizes.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_pony_sizes.py new file mode 100644 index 00000000000..69af8a41f58 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_pony_sizes.py @@ -0,0 +1,52 @@ +# 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.pony_sizes import PonySizes # noqa: E501 + +class TestPonySizes(unittest.TestCase): + """PonySizes unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PonySizes: + """Test PonySizes + 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 `PonySizes` + """ + model = PonySizes() # noqa: E501 + if include_optional: + return PonySizes( + type = 2.0 + ) + else: + return PonySizes( + ) + """ + + def testPonySizes(self): + """Test PonySizes""" + # 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_type.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_type.py new file mode 100644 index 00000000000..9738be707f2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_type.py @@ -0,0 +1,34 @@ +# 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.type import Type # noqa: E501 + +class TestType(unittest.TestCase): + """Type unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testType(self): + """Test Type""" + # inst = Type() + +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 e9cb10689de..97c491419a4 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PonySizes.md docs/PoopCleaning.md docs/PrimitiveString.md docs/PropertyMap.md @@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md +docs/Type.md docs/UnnamedDictWithAdditionalModelListProperties.md docs/UnnamedDictWithAdditionalStringListProperties.md docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -215,6 +217,7 @@ petstore_api/models/parent.py petstore_api/models/parent_with_optional_dict.py petstore_api/models/pet.py petstore_api/models/pig.py +petstore_api/models/pony_sizes.py petstore_api/models/poop_cleaning.py petstore_api/models/primitive_string.py petstore_api/models/property_map.py @@ -238,6 +241,7 @@ petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/test_model_with_enum_default.py petstore_api/models/test_object_for_multipart_requests_request_marker.py petstore_api/models/tiger.py +petstore_api/models/type.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/upload_file_with_additional_properties_request_object.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index ccfeba8f72e..da1b17db861 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -231,6 +231,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PonySizes](docs/PonySizes.md) - [PoopCleaning](docs/PoopCleaning.md) - [PrimitiveString](docs/PrimitiveString.md) - [PropertyMap](docs/PropertyMap.md) @@ -254,6 +255,7 @@ Class | Method | HTTP request | Description - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) + - [Type](docs/Type.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md) - [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md) diff --git a/samples/openapi3/client/petstore/python/docs/PonySizes.md b/samples/openapi3/client/petstore/python/docs/PonySizes.md new file mode 100644 index 00000000000..ced44c87206 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/PonySizes.md @@ -0,0 +1,29 @@ +# PonySizes + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | [**Type**](Type.md) | | [optional] + +## Example + +```python +from petstore_api.models.pony_sizes import PonySizes + +# TODO update the JSON string below +json = "{}" +# create an instance of PonySizes from a JSON string +pony_sizes_instance = PonySizes.from_json(json) +# print the JSON string representation of the object +print(PonySizes.to_json()) + +# convert the object into a dict +pony_sizes_dict = pony_sizes_instance.to_dict() +# create an instance of PonySizes from a dict +pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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/Type.md b/samples/openapi3/client/petstore/python/docs/Type.md new file mode 100644 index 00000000000..f7ff2903a72 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Type.md @@ -0,0 +1,16 @@ +# Type + + +## Enum + +* `NUMBER_2_DOT_0` (value: `2.0`) + +* `NUMBER_1_DOT_0` (value: `1.0`) + +* `NUMBER_0_DOT_5` (value: `0.5`) + +* `NUMBER_0_DOT_25` (value: `0.25`) + +[[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 50788f3e21c..21f88b7adb3 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -116,6 +116,7 @@ __all__ = [ "ParentWithOptionalDict", "Pet", "Pig", + "PonySizes", "PoopCleaning", "PrimitiveString", "PropertyMap", @@ -139,6 +140,7 @@ __all__ = [ "TestModelWithEnumDefault", "TestObjectForMultipartRequestsRequestMarker", "Tiger", + "Type", "UnnamedDictWithAdditionalModelListProperties", "UnnamedDictWithAdditionalStringListProperties", "UploadFileWithAdditionalPropertiesRequestObject", @@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict from petstore_api.models.pet import Pet as Pet from petstore_api.models.pig import Pig as Pig +from petstore_api.models.pony_sizes import PonySizes as PonySizes from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString from petstore_api.models.property_map import PropertyMap as PropertyMap @@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger as Tiger +from petstore_api.models.type import Type as Type from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject 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 fc1f4acbdaf..c9dd877ed2a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict from petstore_api.models.pet import Pet from petstore_api.models.pig import Pig +from petstore_api.models.pony_sizes import PonySizes from petstore_api.models.poop_cleaning import PoopCleaning from petstore_api.models.primitive_string import PrimitiveString from petstore_api.models.property_map import PropertyMap @@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker from petstore_api.models.tiger import Tiger +from petstore_api.models.type import Type 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.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py new file mode 100644 index 00000000000..74efce9a4d0 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.type import Type +from typing import Optional, Set +from typing_extensions import Self + +class PonySizes(BaseModel): + """ + PonySizes + """ # noqa: E501 + type: Optional[Type] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["type"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PonySizes from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PonySizes from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "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/type.py b/samples/openapi3/client/petstore/python/petstore_api/models/type.py new file mode 100644 index 00000000000..35a847de894 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/type.py @@ -0,0 +1,39 @@ +# 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 json +from enum import Enum +from typing_extensions import Self + + +class Type(int, Enum): + """ + Type + """ + + """ + allowed enum values + """ + NUMBER_2_DOT_0 = 2.0 + NUMBER_1_DOT_0 = 1.0 + NUMBER_0_DOT_5 = 0.5 + NUMBER_0_DOT_25 = 0.25 + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Type from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python/test/test_pony_sizes.py b/samples/openapi3/client/petstore/python/test/test_pony_sizes.py new file mode 100644 index 00000000000..8586169f798 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_pony_sizes.py @@ -0,0 +1,51 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.pony_sizes import PonySizes + +class TestPonySizes(unittest.TestCase): + """PonySizes unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PonySizes: + """Test PonySizes + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PonySizes` + """ + model = PonySizes() + if include_optional: + return PonySizes( + type = 2.0 + ) + else: + return PonySizes( + ) + """ + + def testPonySizes(self): + """Test PonySizes""" + # 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_type.py b/samples/openapi3/client/petstore/python/test/test_type.py new file mode 100644 index 00000000000..ecafff8199d --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_type.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.type import Type + +class TestType(unittest.TestCase): + """Type unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testType(self): + """Test Type""" + # inst = Type() + +if __name__ == '__main__': + unittest.main()