From 17b853711669e83d34f08804714df5973685d97f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 8 Jun 2024 16:21:34 +0800 Subject: [PATCH 1/2] add enum default value tests to python clients --- ...ith-fake-endpoints-models-for-testing.yaml | 39 ++++++++++++++++++- .../python-aiohttp/.openapi-generator/FILES | 6 +++ .../client/petstore/python-aiohttp/README.md | 3 ++ .../python-aiohttp/petstore_api/__init__.py | 3 ++ .../petstore_api/models/__init__.py | 3 ++ .../.openapi-generator/FILES | 6 +++ .../python-pydantic-v1-aiohttp/README.md | 3 ++ .../petstore_api/__init__.py | 3 ++ .../petstore_api/models/__init__.py | 3 ++ .../.openapi-generator/FILES | 6 +++ .../petstore/python-pydantic-v1/README.md | 3 ++ .../petstore_api/__init__.py | 3 ++ .../petstore_api/models/__init__.py | 3 ++ .../petstore/python/.openapi-generator/FILES | 6 +++ .../openapi3/client/petstore/python/README.md | 3 ++ .../petstore/python/petstore_api/__init__.py | 3 ++ .../python/petstore_api/models/__init__.py | 3 ++ 17 files changed, 98 insertions(+), 1 deletion(-) 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 7f5925943583..51eb757d3746 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 @@ -2792,4 +2792,41 @@ components: - properties: _value: type: string - type: object \ No newline at end of file + type: object + TestEnum: + type: string + enum: + - ONE + - TWO + - THREE + - foUr + TestEnumWithDefault: + type: string + enum: + - EIN + - ZWEI + - DREI + default: ZWEI + TestModelWithEnumDefault: + type: object + required: + - test_enum + properties: + test_enum: + $ref: "#/components/schemas/TestEnum" + test_string: + type: string + example: "Just some string" + test_enum_with_default: + $ref: "#/components/schemas/TestEnumWithDefault" + test_string_with_default: + type: string + example: "More string" + default: "ahoy matey" + test_inline_defined_enum_with_default: + type: string + enum: + - A + - B + - C + default: B diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 6b44ba44379a..8b7953128a76 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -101,9 +101,12 @@ docs/StoreApi.md docs/Tag.md docs/Task.md docs/TaskActivity.md +docs/TestEnum.md +docs/TestEnumWithDefault.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -218,9 +221,12 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/task.py petstore_api/models/task_activity.py +petstore_api/models/test_enum.py +petstore_api/models/test_enum_with_default.py petstore_api/models/test_error_responses_with_model400_response.py petstore_api/models/test_error_responses_with_model404_response.py 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/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index d7fb2bd4d0a7..df31dba03246 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -241,9 +241,12 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [Task](docs/Task.md) - [TaskActivity](docs/TaskActivity.md) + - [TestEnum](docs/TestEnum.md) + - [TestEnumWithDefault](docs/TestEnumWithDefault.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.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 3f6c3aabf138..efc802ab039e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -130,9 +130,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 30718c766d7d..22498dd88fcd 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 @@ -105,9 +105,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 5bd01d524209..ae45c6c2c954 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 @@ -101,9 +101,12 @@ docs/StoreApi.md docs/Tag.md docs/Task.md docs/TaskActivity.md +docs/TestEnum.md +docs/TestEnumWithDefault.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -218,9 +221,12 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/task.py petstore_api/models/task_activity.py +petstore_api/models/test_enum.py +petstore_api/models/test_enum_with_default.py petstore_api/models/test_error_responses_with_model400_response.py petstore_api/models/test_error_responses_with_model404_response.py 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/unnamed_dict_with_additional_model_list_properties.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 83682c8061f6..374ad59f8b0a 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -242,9 +242,12 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [Task](docs/Task.md) - [TaskActivity](docs/TaskActivity.md) + - [TestEnum](docs/TestEnum.md) + - [TestEnumWithDefault](docs/TestEnumWithDefault.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.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 c0b99d8bf822..87a7d672b9a9 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 @@ -130,9 +130,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 2124d65dc346..ffa70bc3422c 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 @@ -105,9 +105,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 5bd01d524209..ae45c6c2c954 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -101,9 +101,12 @@ docs/StoreApi.md docs/Tag.md docs/Task.md docs/TaskActivity.md +docs/TestEnum.md +docs/TestEnumWithDefault.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -218,9 +221,12 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/task.py petstore_api/models/task_activity.py +petstore_api/models/test_enum.py +petstore_api/models/test_enum_with_default.py petstore_api/models/test_error_responses_with_model400_response.py petstore_api/models/test_error_responses_with_model404_response.py 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/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 0dc87a0af0f2..26bf6a1889c0 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -242,9 +242,12 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [Task](docs/Task.md) - [TaskActivity](docs/TaskActivity.md) + - [TestEnum](docs/TestEnum.md) + - [TestEnumWithDefault](docs/TestEnumWithDefault.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.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 c0b99d8bf822..87a7d672b9a9 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 @@ -130,9 +130,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 2124d65dc346..ffa70bc3422c 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 @@ -105,9 +105,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 6b44ba44379a..8b7953128a76 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -101,9 +101,12 @@ docs/StoreApi.md docs/Tag.md docs/Task.md docs/TaskActivity.md +docs/TestEnum.md +docs/TestEnumWithDefault.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestModelWithEnumDefault.md docs/TestObjectForMultipartRequestsRequestMarker.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -218,9 +221,12 @@ petstore_api/models/special_name.py petstore_api/models/tag.py petstore_api/models/task.py petstore_api/models/task_activity.py +petstore_api/models/test_enum.py +petstore_api/models/test_enum_with_default.py petstore_api/models/test_error_responses_with_model400_response.py petstore_api/models/test_error_responses_with_model404_response.py 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/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 38171d81ae03..65c7ebf343e6 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -241,9 +241,12 @@ Class | Method | HTTP request | Description - [Tag](docs/Tag.md) - [Task](docs/Task.md) - [TaskActivity](docs/TaskActivity.md) + - [TestEnum](docs/TestEnum.md) + - [TestEnumWithDefault](docs/TestEnumWithDefault.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md) - [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index 3f6c3aabf138..efc802ab039e 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -130,9 +130,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties 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 30718c766d7d..22498dd88fcd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -105,9 +105,12 @@ from petstore_api.models.tag import Tag from petstore_api.models.task import Task from petstore_api.models.task_activity import TaskActivity +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest +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.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties From 91129bb56aacf11082920f5cb93afd9b2985de16 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 8 Jun 2024 16:36:41 +0800 Subject: [PATCH 2/2] add new files --- .../petstore/python-aiohttp/docs/TestEnum.md | 16 +++ .../docs/TestEnumWithDefault.md | 14 ++ .../docs/TestModelWithEnumDefault.md | 33 +++++ .../petstore_api/models/test_enum.py | 39 ++++++ .../models/test_enum_with_default.py | 38 ++++++ .../models/test_model_with_enum_default.py | 107 ++++++++++++++++ .../python-aiohttp/test/test_test_enum.py | 33 +++++ .../test/test_test_enum_with_default.py | 33 +++++ .../test/test_test_model_with_enum_default.py | 56 ++++++++ .../docs/TestEnum.md | 16 +++ .../docs/TestEnumWithDefault.md | 14 ++ .../docs/TestModelWithEnumDefault.md | 32 +++++ .../petstore_api/models/test_enum.py | 42 ++++++ .../models/test_enum_with_default.py | 41 ++++++ .../models/test_model_with_enum_default.py | 91 +++++++++++++ .../test/test_test_enum.py | 34 +++++ .../test/test_test_enum_with_default.py | 34 +++++ .../test/test_test_model_with_enum_default.py | 57 +++++++++ .../python-pydantic-v1/docs/TestEnum.md | 16 +++ .../docs/TestEnumWithDefault.md | 14 ++ .../docs/TestModelWithEnumDefault.md | 32 +++++ .../petstore_api/models/test_enum.py | 42 ++++++ .../models/test_enum_with_default.py | 41 ++++++ .../models/test_model_with_enum_default.py | 103 +++++++++++++++ .../python-pydantic-v1/test/test_test_enum.py | 34 +++++ .../test/test_test_enum_with_default.py | 34 +++++ .../test/test_test_model_with_enum_default.py | 57 +++++++++ .../client/petstore/python/docs/TestEnum.md | 16 +++ .../python/docs/TestEnumWithDefault.md | 14 ++ .../python/docs/TestModelWithEnumDefault.md | 33 +++++ .../python/petstore_api/models/test_enum.py | 39 ++++++ .../models/test_enum_with_default.py | 38 ++++++ .../models/test_model_with_enum_default.py | 120 ++++++++++++++++++ .../petstore/python/test/test_test_enum.py | 33 +++++ .../test/test_test_enum_with_default.py | 33 +++++ .../test/test_test_model_with_enum_default.py | 56 ++++++++ 36 files changed, 1485 insertions(+) create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnum.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnumWithDefault.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestModelWithEnumDefault.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnum.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnumWithDefault.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/TestModelWithEnumDefault.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python/docs/TestEnum.md create mode 100644 samples/openapi3/client/petstore/python/docs/TestEnumWithDefault.md create mode 100644 samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/test_enum.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py create mode 100644 samples/openapi3/client/petstore/python/test/test_test_enum.py create mode 100644 samples/openapi3/client/petstore/python/test/test_test_enum_with_default.py create mode 100644 samples/openapi3/client/petstore/python/test/test_test_model_with_enum_default.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md new file mode 100644 index 000000000000..612b62bd4dc4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md @@ -0,0 +1,16 @@ +# TestEnum + + +## Enum + +* `ONE` (value: `'ONE'`) + +* `TWO` (value: `'TWO'`) + +* `THREE` (value: `'THREE'`) + +* `FOUR` (value: `'foUr'`) + +[[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/TestEnumWithDefault.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md new file mode 100644 index 000000000000..ac8591c95c04 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestEnumWithDefault.md @@ -0,0 +1,14 @@ +# TestEnumWithDefault + + +## Enum + +* `EIN` (value: `'EIN'`) + +* `ZWEI` (value: `'ZWEI'`) + +* `DREI` (value: `'DREI'`) + +[[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/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md new file mode 100644 index 000000000000..7d46e86deba4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md @@ -0,0 +1,33 @@ +# TestModelWithEnumDefault + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**test_enum** | [**TestEnum**](TestEnum.md) | | +**test_string** | **str** | | [optional] +**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] [default to TestEnumWithDefault.ZWEI] +**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey'] +**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B'] + +## Example + +```python +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +# TODO update the JSON string below +json = "{}" +# create an instance of TestModelWithEnumDefault from a JSON string +test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +# print the JSON string representation of the object +print(TestModelWithEnumDefault.to_json()) + +# convert the object into a dict +test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +# create an instance of TestModelWithEnumDefault from a dict +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_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/models/test_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.py new file mode 100644 index 000000000000..8eae227a84e9 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum.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 TestEnum(str, Enum): + """ + TestEnum + """ + + """ + allowed enum values + """ + ONE = 'ONE' + TWO = 'TWO' + THREE = 'THREE' + FOUR = 'foUr' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py new file mode 100644 index 000000000000..9304d3ab8497 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_enum_with_default.py @@ -0,0 +1,38 @@ +# 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 TestEnumWithDefault(str, Enum): + """ + TestEnumWithDefault + """ + + """ + allowed enum values + """ + EIN = 'EIN' + ZWEI = 'ZWEI' + DREI = 'DREI' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestEnumWithDefault from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py new file mode 100644 index 000000000000..218fa8f16d22 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -0,0 +1,107 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault +from typing import Optional, Set +from typing_extensions import Self + +class TestModelWithEnumDefault(BaseModel): + """ + TestModelWithEnumDefault + """ # noqa: E501 + test_enum: TestEnum + test_string: Optional[StrictStr] = None + test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI + test_string_with_default: Optional[StrictStr] = 'ahoy matey' + test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] + + @field_validator('test_inline_defined_enum_with_default') + def test_inline_defined_enum_with_default_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['A', 'B', 'C']): + raise ValueError("must be one of enum values ('A', 'B', 'C')") + return value + + 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 TestModelWithEnumDefault 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 TestModelWithEnumDefault from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "test_enum": obj.get("test_enum"), + "test_string": obj.get("test_string"), + "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, + "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', + "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum.py new file mode 100644 index 000000000000..aec65edf520f --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum.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.test_enum import TestEnum + +class TestTestEnum(unittest.TestCase): + """TestEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnum(self): + """Test TestEnum""" + # inst = TestEnum() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum_with_default.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum_with_default.py new file mode 100644 index 000000000000..b51e42819555 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_enum_with_default.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.test_enum_with_default import TestEnumWithDefault + +class TestTestEnumWithDefault(unittest.TestCase): + """TestEnumWithDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnumWithDefault(self): + """Test TestEnumWithDefault""" + # inst = TestEnumWithDefault() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_model_with_enum_default.py new file mode 100644 index 000000000000..7d2029d0af92 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_model_with_enum_default.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +class TestTestModelWithEnumDefault(unittest.TestCase): + """TestModelWithEnumDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestModelWithEnumDefault: + """Test TestModelWithEnumDefault + 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 `TestModelWithEnumDefault` + """ + model = TestModelWithEnumDefault() + if include_optional: + return TestModelWithEnumDefault( + test_enum = 'ONE', + test_string = 'Just some string', + test_enum_with_default = 'ZWEI', + test_string_with_default = 'ahoy matey', + test_inline_defined_enum_with_default = 'B' + ) + else: + return TestModelWithEnumDefault( + test_enum = 'ONE', + ) + """ + + def testTestModelWithEnumDefault(self): + """Test TestModelWithEnumDefault""" + # 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/docs/TestEnum.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnum.md new file mode 100644 index 000000000000..612b62bd4dc4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnum.md @@ -0,0 +1,16 @@ +# TestEnum + + +## Enum + +* `ONE` (value: `'ONE'`) + +* `TWO` (value: `'TWO'`) + +* `THREE` (value: `'THREE'`) + +* `FOUR` (value: `'foUr'`) + +[[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/TestEnumWithDefault.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnumWithDefault.md new file mode 100644 index 000000000000..ac8591c95c04 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestEnumWithDefault.md @@ -0,0 +1,14 @@ +# TestEnumWithDefault + + +## Enum + +* `EIN` (value: `'EIN'`) + +* `ZWEI` (value: `'ZWEI'`) + +* `DREI` (value: `'DREI'`) + +[[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/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestModelWithEnumDefault.md new file mode 100644 index 000000000000..7adae701beb2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestModelWithEnumDefault.md @@ -0,0 +1,32 @@ +# TestModelWithEnumDefault + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**test_enum** | [**TestEnum**](TestEnum.md) | | +**test_string** | **str** | | [optional] +**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] +**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey'] +**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B'] + +## Example + +```python +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +# TODO update the JSON string below +json = "{}" +# create an instance of TestModelWithEnumDefault from a JSON string +test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +# print the JSON string representation of the object +print TestModelWithEnumDefault.to_json() + +# convert the object into a dict +test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +# create an instance of TestModelWithEnumDefault from a dict +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum.py new file mode 100644 index 000000000000..f25ab6a8d6d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum.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 TestEnum(str, Enum): + """ + TestEnum + """ + + """ + allowed enum values + """ + ONE = 'ONE' + TWO = 'TWO' + THREE = 'THREE' + FOUR = 'foUr' + + @classmethod + def from_json(cls, json_str: str) -> TestEnum: + """Create an instance of TestEnum from a JSON string""" + return TestEnum(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum_with_default.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum_with_default.py new file mode 100644 index 000000000000..c14a488a041a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_enum_with_default.py @@ -0,0 +1,41 @@ +# 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 TestEnumWithDefault(str, Enum): + """ + TestEnumWithDefault + """ + + """ + allowed enum values + """ + EIN = 'EIN' + ZWEI = 'ZWEI' + DREI = 'DREI' + + @classmethod + def from_json(cls, json_str: str) -> TestEnumWithDefault: + """Create an instance of TestEnumWithDefault from a JSON string""" + return TestEnumWithDefault(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_model_with_enum_default.py new file mode 100644 index 000000000000..7a3481e9d0cd --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic import BaseModel, Field, StrictStr, validator +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault + +class TestModelWithEnumDefault(BaseModel): + """ + TestModelWithEnumDefault + """ + test_enum: TestEnum = Field(...) + test_string: Optional[StrictStr] = None + test_enum_with_default: Optional[TestEnumWithDefault] = None + test_string_with_default: Optional[StrictStr] = 'ahoy matey' + test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + __properties = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] + + @validator('test_inline_defined_enum_with_default') + def test_inline_defined_enum_with_default_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('A', 'B', 'C'): + raise ValueError("must be one of enum values ('A', 'B', 'C')") + return value + + 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) -> TestModelWithEnumDefault: + """Create an instance of TestModelWithEnumDefault 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) -> TestModelWithEnumDefault: + """Create an instance of TestModelWithEnumDefault from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestModelWithEnumDefault.parse_obj(obj) + + _obj = TestModelWithEnumDefault.parse_obj({ + "test_enum": obj.get("test_enum"), + "test_string": obj.get("test_string"), + "test_enum_with_default": obj.get("test_enum_with_default"), + "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', + "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum.py new file mode 100644 index 000000000000..960400d5bb4c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum.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.test_enum import TestEnum # noqa: E501 + +class TestTestEnum(unittest.TestCase): + """TestEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnum(self): + """Test TestEnum""" + # inst = TestEnum() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum_with_default.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum_with_default.py new file mode 100644 index 000000000000..f21e39317476 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_enum_with_default.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.test_enum_with_default import TestEnumWithDefault # noqa: E501 + +class TestTestEnumWithDefault(unittest.TestCase): + """TestEnumWithDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnumWithDefault(self): + """Test TestEnumWithDefault""" + # inst = TestEnumWithDefault() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_model_with_enum_default.py new file mode 100644 index 000000000000..67fc4400dcbe --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_model_with_enum_default.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault # noqa: E501 + +class TestTestModelWithEnumDefault(unittest.TestCase): + """TestModelWithEnumDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestModelWithEnumDefault: + """Test TestModelWithEnumDefault + 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 `TestModelWithEnumDefault` + """ + model = TestModelWithEnumDefault() # noqa: E501 + if include_optional: + return TestModelWithEnumDefault( + test_enum = 'ONE', + test_string = 'Just some string', + test_enum_with_default = 'ZWEI', + test_string_with_default = 'ahoy matey', + test_inline_defined_enum_with_default = 'B' + ) + else: + return TestModelWithEnumDefault( + test_enum = 'ONE', + ) + """ + + def testTestModelWithEnumDefault(self): + """Test TestModelWithEnumDefault""" + # 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/docs/TestEnum.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnum.md new file mode 100644 index 000000000000..612b62bd4dc4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnum.md @@ -0,0 +1,16 @@ +# TestEnum + + +## Enum + +* `ONE` (value: `'ONE'`) + +* `TWO` (value: `'TWO'`) + +* `THREE` (value: `'THREE'`) + +* `FOUR` (value: `'foUr'`) + +[[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/TestEnumWithDefault.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnumWithDefault.md new file mode 100644 index 000000000000..ac8591c95c04 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestEnumWithDefault.md @@ -0,0 +1,14 @@ +# TestEnumWithDefault + + +## Enum + +* `EIN` (value: `'EIN'`) + +* `ZWEI` (value: `'ZWEI'`) + +* `DREI` (value: `'DREI'`) + +[[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/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestModelWithEnumDefault.md new file mode 100644 index 000000000000..7adae701beb2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestModelWithEnumDefault.md @@ -0,0 +1,32 @@ +# TestModelWithEnumDefault + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**test_enum** | [**TestEnum**](TestEnum.md) | | +**test_string** | **str** | | [optional] +**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] +**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey'] +**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B'] + +## Example + +```python +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +# TODO update the JSON string below +json = "{}" +# create an instance of TestModelWithEnumDefault from a JSON string +test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +# print the JSON string representation of the object +print TestModelWithEnumDefault.to_json() + +# convert the object into a dict +test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +# create an instance of TestModelWithEnumDefault from a dict +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum.py new file mode 100644 index 000000000000..f25ab6a8d6d2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum.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 TestEnum(str, Enum): + """ + TestEnum + """ + + """ + allowed enum values + """ + ONE = 'ONE' + TWO = 'TWO' + THREE = 'THREE' + FOUR = 'foUr' + + @classmethod + def from_json(cls, json_str: str) -> TestEnum: + """Create an instance of TestEnum from a JSON string""" + return TestEnum(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum_with_default.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum_with_default.py new file mode 100644 index 000000000000..c14a488a041a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_enum_with_default.py @@ -0,0 +1,41 @@ +# 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 TestEnumWithDefault(str, Enum): + """ + TestEnumWithDefault + """ + + """ + allowed enum values + """ + EIN = 'EIN' + ZWEI = 'ZWEI' + DREI = 'DREI' + + @classmethod + def from_json(cls, json_str: str) -> TestEnumWithDefault: + """Create an instance of TestEnumWithDefault from a JSON string""" + return TestEnumWithDefault(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_model_with_enum_default.py new file mode 100644 index 000000000000..092b584a3606 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_model_with_enum_default.py @@ -0,0 +1,103 @@ +# 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, Field, StrictStr, validator +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault + +class TestModelWithEnumDefault(BaseModel): + """ + TestModelWithEnumDefault + """ + test_enum: TestEnum = Field(...) + test_string: Optional[StrictStr] = None + test_enum_with_default: Optional[TestEnumWithDefault] = None + test_string_with_default: Optional[StrictStr] = 'ahoy matey' + test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + additional_properties: Dict[str, Any] = {} + __properties = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] + + @validator('test_inline_defined_enum_with_default') + def test_inline_defined_enum_with_default_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in ('A', 'B', 'C'): + raise ValueError("must be one of enum values ('A', 'B', 'C')") + return value + + 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) -> TestModelWithEnumDefault: + """Create an instance of TestModelWithEnumDefault 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) -> TestModelWithEnumDefault: + """Create an instance of TestModelWithEnumDefault from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestModelWithEnumDefault.parse_obj(obj) + + _obj = TestModelWithEnumDefault.parse_obj({ + "test_enum": obj.get("test_enum"), + "test_string": obj.get("test_string"), + "test_enum_with_default": obj.get("test_enum_with_default"), + "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', + "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum.py new file mode 100644 index 000000000000..960400d5bb4c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum.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.test_enum import TestEnum # noqa: E501 + +class TestTestEnum(unittest.TestCase): + """TestEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnum(self): + """Test TestEnum""" + # inst = TestEnum() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum_with_default.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum_with_default.py new file mode 100644 index 000000000000..f21e39317476 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_enum_with_default.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.test_enum_with_default import TestEnumWithDefault # noqa: E501 + +class TestTestEnumWithDefault(unittest.TestCase): + """TestEnumWithDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnumWithDefault(self): + """Test TestEnumWithDefault""" + # inst = TestEnumWithDefault() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_model_with_enum_default.py new file mode 100644 index 000000000000..67fc4400dcbe --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_model_with_enum_default.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault # noqa: E501 + +class TestTestModelWithEnumDefault(unittest.TestCase): + """TestModelWithEnumDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestModelWithEnumDefault: + """Test TestModelWithEnumDefault + 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 `TestModelWithEnumDefault` + """ + model = TestModelWithEnumDefault() # noqa: E501 + if include_optional: + return TestModelWithEnumDefault( + test_enum = 'ONE', + test_string = 'Just some string', + test_enum_with_default = 'ZWEI', + test_string_with_default = 'ahoy matey', + test_inline_defined_enum_with_default = 'B' + ) + else: + return TestModelWithEnumDefault( + test_enum = 'ONE', + ) + """ + + def testTestModelWithEnumDefault(self): + """Test TestModelWithEnumDefault""" + # 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/docs/TestEnum.md b/samples/openapi3/client/petstore/python/docs/TestEnum.md new file mode 100644 index 000000000000..612b62bd4dc4 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TestEnum.md @@ -0,0 +1,16 @@ +# TestEnum + + +## Enum + +* `ONE` (value: `'ONE'`) + +* `TWO` (value: `'TWO'`) + +* `THREE` (value: `'THREE'`) + +* `FOUR` (value: `'foUr'`) + +[[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/TestEnumWithDefault.md b/samples/openapi3/client/petstore/python/docs/TestEnumWithDefault.md new file mode 100644 index 000000000000..ac8591c95c04 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TestEnumWithDefault.md @@ -0,0 +1,14 @@ +# TestEnumWithDefault + + +## Enum + +* `EIN` (value: `'EIN'`) + +* `ZWEI` (value: `'ZWEI'`) + +* `DREI` (value: `'DREI'`) + +[[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/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md new file mode 100644 index 000000000000..7d46e86deba4 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md @@ -0,0 +1,33 @@ +# TestModelWithEnumDefault + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**test_enum** | [**TestEnum**](TestEnum.md) | | +**test_string** | **str** | | [optional] +**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] [default to TestEnumWithDefault.ZWEI] +**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey'] +**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B'] + +## Example + +```python +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +# TODO update the JSON string below +json = "{}" +# create an instance of TestModelWithEnumDefault from a JSON string +test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +# print the JSON string representation of the object +print(TestModelWithEnumDefault.to_json()) + +# convert the object into a dict +test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +# create an instance of TestModelWithEnumDefault from a dict +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_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/models/test_enum.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_enum.py new file mode 100644 index 000000000000..8eae227a84e9 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_enum.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 TestEnum(str, Enum): + """ + TestEnum + """ + + """ + allowed enum values + """ + ONE = 'ONE' + TWO = 'TWO' + THREE = 'THREE' + FOUR = 'foUr' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestEnum from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_enum_with_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_enum_with_default.py new file mode 100644 index 000000000000..9304d3ab8497 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_enum_with_default.py @@ -0,0 +1,38 @@ +# 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 TestEnumWithDefault(str, Enum): + """ + TestEnumWithDefault + """ + + """ + allowed enum values + """ + EIN = 'EIN' + ZWEI = 'ZWEI' + DREI = 'DREI' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestEnumWithDefault from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py new file mode 100644 index 000000000000..4bff5e699a37 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -0,0 +1,120 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from petstore_api.models.test_enum import TestEnum +from petstore_api.models.test_enum_with_default import TestEnumWithDefault +from typing import Optional, Set +from typing_extensions import Self + +class TestModelWithEnumDefault(BaseModel): + """ + TestModelWithEnumDefault + """ # noqa: E501 + test_enum: TestEnum + test_string: Optional[StrictStr] = None + test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI + test_string_with_default: Optional[StrictStr] = 'ahoy matey' + test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] + + @field_validator('test_inline_defined_enum_with_default') + def test_inline_defined_enum_with_default_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['A', 'B', 'C']): + raise ValueError("must be one of enum values ('A', 'B', 'C')") + return value + + 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 TestModelWithEnumDefault 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 TestModelWithEnumDefault from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "test_enum": obj.get("test_enum"), + "test_string": obj.get("test_string"), + "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, + "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', + "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' + }) + # 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_test_enum.py b/samples/openapi3/client/petstore/python/test/test_test_enum.py new file mode 100644 index 000000000000..aec65edf520f --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_test_enum.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.test_enum import TestEnum + +class TestTestEnum(unittest.TestCase): + """TestEnum unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnum(self): + """Test TestEnum""" + # inst = TestEnum() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_test_enum_with_default.py b/samples/openapi3/client/petstore/python/test/test_test_enum_with_default.py new file mode 100644 index 000000000000..b51e42819555 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_test_enum_with_default.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.test_enum_with_default import TestEnumWithDefault + +class TestTestEnumWithDefault(unittest.TestCase): + """TestEnumWithDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTestEnumWithDefault(self): + """Test TestEnumWithDefault""" + # inst = TestEnumWithDefault() + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/test/test_test_model_with_enum_default.py new file mode 100644 index 000000000000..7d2029d0af92 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_test_model_with_enum_default.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault + +class TestTestModelWithEnumDefault(unittest.TestCase): + """TestModelWithEnumDefault unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestModelWithEnumDefault: + """Test TestModelWithEnumDefault + 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 `TestModelWithEnumDefault` + """ + model = TestModelWithEnumDefault() + if include_optional: + return TestModelWithEnumDefault( + test_enum = 'ONE', + test_string = 'Just some string', + test_enum_with_default = 'ZWEI', + test_string_with_default = 'ahoy matey', + test_inline_defined_enum_with_default = 'B' + ) + else: + return TestModelWithEnumDefault( + test_enum = 'ONE', + ) + """ + + def testTestModelWithEnumDefault(self): + """Test TestModelWithEnumDefault""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()