From c9204c4330ac9bd6bddc5e8f1591845066d2907c Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 31 Jan 2024 11:29:15 +0800 Subject: [PATCH] Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple (#17749) * Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple In this excerpt of the mustache template, the matching behaviour is bugged when there is only one element in the tuple notation. A single string with the tuple notation, e.g., `("string")`, will result in a string, and when values are compared with the string, it will do a `contains` match instead of an exact match, which is unintended behaviour. * Update with samples, step 3 * Add test spec and regenerate samples * Update samples * Update spec and samples * update samples --------- Co-authored-by: Edmund Loo Co-authored-by: Edmund Loo --- .../resources/python/model_generic.mustache | 4 +- ...ith-fake-endpoints-models-for-testing.yaml | 61 +++++++ .../openapi_client/models/default_value.py | 2 +- .../openapi_client/models/pet.py | 2 +- .../openapi_client/models/query.py | 2 +- .../openapi_client/models/default_value.py | 2 +- .../python/openapi_client/models/pet.py | 2 +- .../python/openapi_client/models/query.py | 2 +- .../python-aiohttp/.openapi-generator/FILES | 10 ++ .../client/petstore/python-aiohttp/README.md | 5 + .../petstore/python-aiohttp/docs/Bathing.md | 31 ++++ .../petstore/python-aiohttp/docs/Feeding.md | 31 ++++ .../python-aiohttp/docs/PoopCleaning.md | 31 ++++ .../petstore/python-aiohttp/docs/Task.md | 31 ++++ .../python-aiohttp/docs/TaskActivity.md | 31 ++++ .../python-aiohttp/petstore_api/__init__.py | 5 + .../petstore_api/models/__init__.py | 5 + .../petstore_api/models/bathing.py | 105 ++++++++++++ .../petstore_api/models/enum_arrays.py | 4 +- .../petstore_api/models/enum_test.py | 10 +- .../petstore_api/models/feeding.py | 105 ++++++++++++ .../petstore_api/models/map_test.py | 2 +- .../petstore_api/models/order.py | 2 +- .../python-aiohttp/petstore_api/models/pet.py | 2 +- .../petstore_api/models/poop_cleaning.py | 105 ++++++++++++ .../petstore_api/models/special_name.py | 2 +- .../petstore_api/models/task.py | 93 +++++++++++ .../petstore_api/models/task_activity.py | 151 +++++++++++++++++ .../python-aiohttp/test/test_bathing.py | 57 +++++++ .../python-aiohttp/test/test_feeding.py | 57 +++++++ .../python-aiohttp/test/test_poop_cleaning.py | 57 +++++++ .../petstore/python-aiohttp/test/test_task.py | 55 +++++++ .../python-aiohttp/test/test_task_activity.py | 57 +++++++ .../.openapi-generator/FILES | 10 ++ .../python-pydantic-v1-aiohttp/README.md | 5 + .../docs/Bathing.md | 30 ++++ .../docs/Feeding.md | 30 ++++ .../docs/PoopCleaning.md | 30 ++++ .../python-pydantic-v1-aiohttp/docs/Task.md | 30 ++++ .../docs/TaskActivity.md | 30 ++++ .../petstore_api/__init__.py | 5 + .../petstore_api/models/__init__.py | 5 + .../petstore_api/models/bathing.py | 89 ++++++++++ .../petstore_api/models/feeding.py | 89 ++++++++++ .../petstore_api/models/poop_cleaning.py | 89 ++++++++++ .../petstore_api/models/task.py | 77 +++++++++ .../petstore_api/models/task_activity.py | 155 ++++++++++++++++++ .../test/test_bathing.py | 57 +++++++ .../test/test_feeding.py | 57 +++++++ .../test/test_poop_cleaning.py | 57 +++++++ .../test/test_task.py | 55 +++++++ .../test/test_task_activity.py | 57 +++++++ .../.openapi-generator/FILES | 10 ++ .../petstore/python-pydantic-v1/README.md | 5 + .../python-pydantic-v1/docs/Bathing.md | 30 ++++ .../python-pydantic-v1/docs/Feeding.md | 30 ++++ .../python-pydantic-v1/docs/PoopCleaning.md | 30 ++++ .../petstore/python-pydantic-v1/docs/Task.md | 30 ++++ .../python-pydantic-v1/docs/TaskActivity.md | 30 ++++ .../petstore_api/__init__.py | 5 + .../petstore_api/models/__init__.py | 5 + .../petstore_api/models/bathing.py | 101 ++++++++++++ .../petstore_api/models/feeding.py | 101 ++++++++++++ .../petstore_api/models/poop_cleaning.py | 101 ++++++++++++ .../petstore_api/models/task.py | 89 ++++++++++ .../petstore_api/models/task_activity.py | 155 ++++++++++++++++++ .../python-pydantic-v1/test/test_bathing.py | 57 +++++++ .../python-pydantic-v1/test/test_feeding.py | 57 +++++++ .../test/test_poop_cleaning.py | 57 +++++++ .../python-pydantic-v1/test/test_task.py | 55 +++++++ .../test/test_task_activity.py | 57 +++++++ .../petstore/python/.openapi-generator/FILES | 10 ++ .../openapi3/client/petstore/python/README.md | 5 + .../client/petstore/python/docs/Bathing.md | 31 ++++ .../client/petstore/python/docs/Feeding.md | 31 ++++ .../petstore/python/docs/PoopCleaning.md | 31 ++++ .../client/petstore/python/docs/Task.md | 31 ++++ .../petstore/python/docs/TaskActivity.md | 31 ++++ .../petstore/python/petstore_api/__init__.py | 5 + .../python/petstore_api/models/__init__.py | 5 + .../python/petstore_api/models/bathing.py | 118 +++++++++++++ .../python/petstore_api/models/enum_arrays.py | 4 +- .../python/petstore_api/models/enum_test.py | 10 +- .../python/petstore_api/models/feeding.py | 118 +++++++++++++ .../python/petstore_api/models/map_test.py | 2 +- .../python/petstore_api/models/order.py | 2 +- .../python/petstore_api/models/pet.py | 2 +- .../petstore_api/models/poop_cleaning.py | 118 +++++++++++++ .../petstore_api/models/special_name.py | 2 +- .../python/petstore_api/models/task.py | 106 ++++++++++++ .../petstore_api/models/task_activity.py | 151 +++++++++++++++++ .../petstore/python/test/test_bathing.py | 57 +++++++ .../petstore/python/test/test_feeding.py | 57 +++++++ .../python/test/test_poop_cleaning.py | 57 +++++++ .../client/petstore/python/test/test_task.py | 55 +++++++ .../python/test/test_task_activity.py | 57 +++++++ 96 files changed, 4149 insertions(+), 30 deletions(-) create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/Task.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_bathing.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_feeding.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_task.py create mode 100644 samples/openapi3/client/petstore/python-aiohttp/test/test_task_activity.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Bathing.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Feeding.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PoopCleaning.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Task.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TaskActivity.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/bathing.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/feeding.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task_activity.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_bathing.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_feeding.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task_activity.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/Bathing.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/Feeding.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/PoopCleaning.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/Task.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/docs/TaskActivity.md create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/bathing.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/feeding.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task_activity.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_bathing.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_feeding.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_task.py create mode 100644 samples/openapi3/client/petstore/python-pydantic-v1/test/test_task_activity.py create mode 100644 samples/openapi3/client/petstore/python/docs/Bathing.md create mode 100644 samples/openapi3/client/petstore/python/docs/Feeding.md create mode 100644 samples/openapi3/client/petstore/python/docs/PoopCleaning.md create mode 100644 samples/openapi3/client/petstore/python/docs/Task.md create mode 100644 samples/openapi3/client/petstore/python/docs/TaskActivity.md create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/bathing.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/feeding.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/task.py create mode 100644 samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py create mode 100644 samples/openapi3/client/petstore/python/test/test_bathing.py create mode 100644 samples/openapi3/client/petstore/python/test/test_feeding.py create mode 100644 samples/openapi3/client/petstore/python/test/test_poop_cleaning.py create mode 100644 samples/openapi3/client/petstore/python/test/test_task.py create mode 100644 samples/openapi3/client/petstore/python/test/test_task_activity.py diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index c9df8781097..fe470f8295f 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -64,11 +64,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/required}} {{#isArray}} for i in value: - if i not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}): + if i not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") {{/isArray}} {{^isArray}} - if value not in ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}): + if value not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") {{/isArray}} return value 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 0081123ded6..1e992fab466 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 @@ -1579,6 +1579,67 @@ components: type: string xml: name: Tag + PoopCleaning: + type: object + properties: + task_name: + type: string + enum: [cleaning] + function_name: + type: string + enum: [care] + content: + type: string + required: + - task_name + - function_name + - content + Feeding: + type: object + properties: + task_name: + type: string + enum: [cleaning] + function_name: + type: string + enum: [care_nourish] + content: + type: string + required: + - task_name + - function_name + - content + Bathing: + type: object + properties: + task_name: + type: string + enum: [cleaning_deep] + function_name: + type: string + enum: [care_nourish] + content: + type: string + required: + - task_name + - function_name + - content + Task: + title: Task + type: object + description: Used to test oneOf enums with only one string value. + properties: + id: + type: string + format: uuid + activity: + oneOf: + - $ref: '#/components/schemas/PoopCleaning' + - $ref: '#/components/schemas/Feeding' + - $ref: '#/components/schemas/Bathing' + required: + - id + - activity Pet: type: object required: diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index aaaeb2682c1..b5311d7a43c 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -45,7 +45,7 @@ class DefaultValue(BaseModel): return value for i in value: - if i not in ('success', 'failure', 'unclassified'): + if i not in set(['success', 'failure', 'unclassified']): raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')") return value diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index 54caa7b78b9..24eb8075e61 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -43,7 +43,7 @@ class Pet(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index 2f734303013..0d2c05017fd 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -38,7 +38,7 @@ class Query(BaseModel): return value for i in value: - if i not in ('SUCCESS', 'FAILURE', 'SKIPPED'): + if i not in set(['SUCCESS', 'FAILURE', 'SKIPPED']): raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')") return value diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 80cdb03a45d..a8c27c721cd 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -45,7 +45,7 @@ class DefaultValue(BaseModel): return value for i in value: - if i not in ('success', 'failure', 'unclassified'): + if i not in set(['success', 'failure', 'unclassified']): raise ValueError("each list item must be one of ('success', 'failure', 'unclassified')") return value diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 62c473647ba..a3f9d65d710 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -43,7 +43,7 @@ class Pet(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 2f734303013..0d2c05017fd 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -38,7 +38,7 @@ class Query(BaseModel): return value for i in value: - if i not in ('SUCCESS', 'FAILURE', 'SKIPPED'): + if i not in set(['SUCCESS', 'FAILURE', 'SKIPPED']): raise ValueError("each list item must be one of ('SUCCESS', 'FAILURE', 'SKIPPED')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index b85011e9790..b262850d70c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BasquePig.md +docs/Bathing.md docs/Capitalization.md docs/Cat.md docs/Category.md @@ -38,6 +39,7 @@ docs/EnumString2.md docs/EnumTest.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/Feeding.md docs/File.md docs/FileSchemaTestClass.md docs/FirstRef.md @@ -74,6 +76,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PoopCleaning.md docs/PropertyNameCollision.md docs/ReadOnlyFirst.md docs/SecondRef.md @@ -84,6 +87,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Task.md +docs/TaskActivity.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -121,6 +126,7 @@ petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/basque_pig.py +petstore_api/models/bathing.py petstore_api/models/capitalization.py petstore_api/models/cat.py petstore_api/models/category.py @@ -139,6 +145,7 @@ petstore_api/models/enum_class.py petstore_api/models/enum_string1.py petstore_api/models/enum_string2.py petstore_api/models/enum_test.py +petstore_api/models/feeding.py petstore_api/models/file.py petstore_api/models/file_schema_test_class.py petstore_api/models/first_ref.py @@ -174,6 +181,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/poop_cleaning.py petstore_api/models/property_name_collision.py petstore_api/models/read_only_first.py petstore_api/models/second_ref.py @@ -183,6 +191,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/task.py +petstore_api/models/task_activity.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 diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 93d1a926bec..cf37ef18e40 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -152,6 +152,7 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BasquePig](docs/BasquePig.md) + - [Bathing](docs/Bathing.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) @@ -170,6 +171,7 @@ Class | Method | HTTP request | Description - [EnumString1](docs/EnumString1.md) - [EnumString2](docs/EnumString2.md) - [EnumTest](docs/EnumTest.md) + - [Feeding](docs/Feeding.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [FirstRef](docs/FirstRef.md) @@ -205,6 +207,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PoopCleaning](docs/PoopCleaning.md) - [PropertyNameCollision](docs/PropertyNameCollision.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SecondRef](docs/SecondRef.md) @@ -214,6 +217,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Task](docs/Task.md) + - [TaskActivity](docs/TaskActivity.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md new file mode 100644 index 00000000000..4c4963bf593 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md @@ -0,0 +1,31 @@ +# Bathing + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.bathing import Bathing + +# TODO update the JSON string below +json = "{}" +# create an instance of Bathing from a JSON string +bathing_instance = Bathing.from_json(json) +# print the JSON string representation of the object +print Bathing.to_json() + +# convert the object into a dict +bathing_dict = bathing_instance.to_dict() +# create an instance of Bathing from a dict +bathing_form_dict = bathing.from_dict(bathing_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/Feeding.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md new file mode 100644 index 00000000000..f0d51f621c2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md @@ -0,0 +1,31 @@ +# Feeding + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.feeding import Feeding + +# TODO update the JSON string below +json = "{}" +# create an instance of Feeding from a JSON string +feeding_instance = Feeding.from_json(json) +# print the JSON string representation of the object +print Feeding.to_json() + +# convert the object into a dict +feeding_dict = feeding_instance.to_dict() +# create an instance of Feeding from a dict +feeding_form_dict = feeding.from_dict(feeding_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/PoopCleaning.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md new file mode 100644 index 00000000000..9fd6b0c3245 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md @@ -0,0 +1,31 @@ +# PoopCleaning + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.poop_cleaning import PoopCleaning + +# TODO update the JSON string below +json = "{}" +# create an instance of PoopCleaning from a JSON string +poop_cleaning_instance = PoopCleaning.from_json(json) +# print the JSON string representation of the object +print PoopCleaning.to_json() + +# convert the object into a dict +poop_cleaning_dict = poop_cleaning_instance.to_dict() +# create an instance of PoopCleaning from a dict +poop_cleaning_form_dict = poop_cleaning.from_dict(poop_cleaning_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/Task.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md new file mode 100644 index 00000000000..6cee08c6fe6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md @@ -0,0 +1,31 @@ +# Task + +Used to test oneOf enums with only one string value. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | | +**activity** | [**TaskActivity**](TaskActivity.md) | | + +## Example + +```python +from petstore_api.models.task import Task + +# TODO update the JSON string below +json = "{}" +# create an instance of Task from a JSON string +task_instance = Task.from_json(json) +# print the JSON string representation of the object +print Task.to_json() + +# convert the object into a dict +task_dict = task_instance.to_dict() +# create an instance of Task from a dict +task_form_dict = task.from_dict(task_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/TaskActivity.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md new file mode 100644 index 00000000000..37f10f9031e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md @@ -0,0 +1,31 @@ +# TaskActivity + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.task_activity import TaskActivity + +# TODO update the JSON string below +json = "{}" +# create an instance of TaskActivity from a JSON string +task_activity_instance = TaskActivity.from_json(json) +# print the JSON string representation of the object +print TaskActivity.to_json() + +# convert the object into a dict +task_activity_dict = task_activity_instance.to_dict() +# create an instance of TaskActivity from a dict +task_activity_form_dict = task_activity.from_dict(task_activity_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index f791bc53112..704dcbaffbd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -51,6 +51,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -69,6 +70,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -104,6 +106,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -113,6 +116,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 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 945dd198de1..554f557cb05 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 @@ -27,6 +27,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -45,6 +46,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -80,6 +82,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -89,6 +92,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py new file mode 100644 index 00000000000..efc48513103 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -0,0 +1,105 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Bathing(BaseModel): + """ + Bathing + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning_deep']): + raise ValueError("must be one of enum values ('cleaning_deep')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care_nourish']): + raise ValueError("must be one of enum values ('care_nourish')") + return value + + model_config = { + "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 Bathing 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 Bathing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 1e957885f83..6bac8225630 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -36,7 +36,7 @@ class EnumArrays(BaseModel): if value is None: return value - if value not in ('>=', '$'): + if value not in set(['>=', '$']): raise ValueError("must be one of enum values ('>=', '$')") return value @@ -47,7 +47,7 @@ class EnumArrays(BaseModel): return value for i in value: - if i not in ('fish', 'crab'): + if i not in set(['fish', 'crab']): raise ValueError("each list item must be one of ('fish', 'crab')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 45308ff4da4..4f2d86483fb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -47,14 +47,14 @@ class EnumTest(BaseModel): if value is None: return value - if value not in ('UPPER', 'lower', ''): + if value not in set(['UPPER', 'lower', '']): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value @field_validator('enum_string_required') def enum_string_required_validate_enum(cls, value): """Validates the enum""" - if value not in ('UPPER', 'lower', ''): + if value not in set(['UPPER', 'lower', '']): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value @@ -64,7 +64,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1, 5, 14): + if value not in set([1, 5, 14]): raise ValueError("must be one of enum values (1, 5, 14)") return value @@ -74,7 +74,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1, -1): + if value not in set([1, -1]): raise ValueError("must be one of enum values (1, -1)") return value @@ -84,7 +84,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1.1, -1.2): + if value not in set([1.1, -1.2]): raise ValueError("must be one of enum values (1.1, -1.2)") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py new file mode 100644 index 00000000000..4c5333d3b16 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -0,0 +1,105 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Feeding(BaseModel): + """ + Feeding + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning']): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care_nourish']): + raise ValueError("must be one of enum values ('care_nourish')") + return value + + model_config = { + "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 Feeding 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 Feeding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 8d0e5a8ad62..bb674830c01 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -38,7 +38,7 @@ class MapTest(BaseModel): if value is None: return value - if value not in ('UPPER', 'lower'): + if value not in set(['UPPER', 'lower']): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index 94f1a306b27..5c08aae91b1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -41,7 +41,7 @@ class Order(BaseModel): if value is None: return value - if value not in ('placed', 'approved', 'delivered'): + if value not in set(['placed', 'approved', 'delivered']): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index 3812cfa2a15..05f24508062 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -43,7 +43,7 @@ class Pet(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py new file mode 100644 index 00000000000..789ef627f0e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -0,0 +1,105 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class PoopCleaning(BaseModel): + """ + PoopCleaning + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning']): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care']): + raise ValueError("must be one of enum values ('care')") + return value + + model_config = { + "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 PoopCleaning 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 PoopCleaning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index caff65e97c1..9029b789f5e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -38,7 +38,7 @@ class SpecialName(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py new file mode 100644 index 00000000000..7fb9e638729 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -0,0 +1,93 @@ +# 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, StrictStr +from typing import Any, ClassVar, Dict, List +from petstore_api.models.task_activity import TaskActivity +from typing import Optional, Set +from typing_extensions import Self + +class Task(BaseModel): + """ + Used to test oneOf enums with only one string value. + """ # noqa: E501 + id: StrictStr + activity: TaskActivity + __properties: ClassVar[List[str]] = ["id", "activity"] + + model_config = { + "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 Task from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of activity + if self.activity: + _dict['activity'] = self.activity.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Task from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py new file mode 100644 index 00000000000..b76c2604597 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -0,0 +1,151 @@ +# 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 +import pprint +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from petstore_api.models.bathing import Bathing +from petstore_api.models.feeding import Feeding +from petstore_api.models.poop_cleaning import PoopCleaning +from pydantic import StrictStr, Field +from typing import Union, List, Optional, Dict +from typing_extensions import Literal, Self + +TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + +class TaskActivity(BaseModel): + """ + TaskActivity + """ + # data type: PoopCleaning + oneof_schema_1_validator: Optional[PoopCleaning] = None + # data type: Feeding + oneof_schema_2_validator: Optional[Feeding] = None + # data type: Bathing + oneof_schema_3_validator: Optional[Bathing] = None + actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None + one_of_schemas: List[str] = Field(default=Literal["Bathing", "Feeding", "PoopCleaning"]) + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = TaskActivity.model_construct() + error_messages = [] + match = 0 + # validate data type: PoopCleaning + if not isinstance(v, PoopCleaning): + error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") + else: + match += 1 + # validate data type: Feeding + if not isinstance(v, Feeding): + error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") + else: + match += 1 + # validate data type: Bathing + if not isinstance(v, Bathing): + error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into PoopCleaning + try: + instance.actual_instance = PoopCleaning.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Feeding + try: + instance.actual_instance = Feeding.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Bathing + try: + instance.actual_instance = Bathing.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_bathing.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_bathing.py new file mode 100644 index 00000000000..583bdcbb09e --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_bathing.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.bathing import Bathing + +class TestBathing(unittest.TestCase): + """Bathing unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Bathing: + """Test Bathing + 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 `Bathing` + """ + model = Bathing() + if include_optional: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testBathing(self): + """Test Bathing""" + # 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_feeding.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_feeding.py new file mode 100644 index 00000000000..a0cdfc8f346 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_feeding.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.feeding import Feeding + +class TestFeeding(unittest.TestCase): + """Feeding unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Feeding: + """Test Feeding + 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 `Feeding` + """ + model = Feeding() + if include_optional: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '' + ) + else: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '', + ) + """ + + def testFeeding(self): + """Test Feeding""" + # 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_poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_poop_cleaning.py new file mode 100644 index 00000000000..4c94fddca97 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_poop_cleaning.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.poop_cleaning import PoopCleaning + +class TestPoopCleaning(unittest.TestCase): + """PoopCleaning unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PoopCleaning: + """Test PoopCleaning + 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 `PoopCleaning` + """ + model = PoopCleaning() + if include_optional: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '' + ) + else: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '', + ) + """ + + def testPoopCleaning(self): + """Test PoopCleaning""" + # 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_task.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_task.py new file mode 100644 index 00000000000..bbbc14a3992 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_task.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.task import Task + +class TestTask(unittest.TestCase): + """Task unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Task: + """Test Task + 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 `Task` + """ + model = Task() + if include_optional: + return Task( + id = '', + activity = None + ) + else: + return Task( + id = '', + activity = None, + ) + """ + + def testTask(self): + """Test Task""" + # 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_task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_task_activity.py new file mode 100644 index 00000000000..2d56d9c5ad3 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_task_activity.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.task_activity import TaskActivity + +class TestTaskActivity(unittest.TestCase): + """TaskActivity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TaskActivity: + """Test TaskActivity + 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 `TaskActivity` + """ + model = TaskActivity() + if include_optional: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testTaskActivity(self): + """Test TaskActivity""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES index 1ef5f596fa1..b03e397c14c 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 @@ -18,6 +18,7 @@ docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BasquePig.md +docs/Bathing.md docs/Capitalization.md docs/Cat.md docs/Category.md @@ -39,6 +40,7 @@ docs/EnumString2.md docs/EnumTest.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/Feeding.md docs/File.md docs/FileSchemaTestClass.md docs/FirstRef.md @@ -74,6 +76,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PoopCleaning.md docs/PropertyNameCollision.md docs/ReadOnlyFirst.md docs/SecondRef.md @@ -84,6 +87,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Task.md +docs/TaskActivity.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -122,6 +127,7 @@ petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/basque_pig.py +petstore_api/models/bathing.py petstore_api/models/capitalization.py petstore_api/models/cat.py petstore_api/models/category.py @@ -140,6 +146,7 @@ petstore_api/models/enum_class.py petstore_api/models/enum_string1.py petstore_api/models/enum_string2.py petstore_api/models/enum_test.py +petstore_api/models/feeding.py petstore_api/models/file.py petstore_api/models/file_schema_test_class.py petstore_api/models/first_ref.py @@ -174,6 +181,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/poop_cleaning.py petstore_api/models/property_name_collision.py petstore_api/models/read_only_first.py petstore_api/models/second_ref.py @@ -183,6 +191,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/task.py +petstore_api/models/task_activity.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 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 b284e2059c8..4912e657ad8 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -154,6 +154,7 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BasquePig](docs/BasquePig.md) + - [Bathing](docs/Bathing.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) @@ -172,6 +173,7 @@ Class | Method | HTTP request | Description - [EnumString1](docs/EnumString1.md) - [EnumString2](docs/EnumString2.md) - [EnumTest](docs/EnumTest.md) + - [Feeding](docs/Feeding.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [FirstRef](docs/FirstRef.md) @@ -206,6 +208,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PoopCleaning](docs/PoopCleaning.md) - [PropertyNameCollision](docs/PropertyNameCollision.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SecondRef](docs/SecondRef.md) @@ -215,6 +218,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Task](docs/Task.md) + - [TaskActivity](docs/TaskActivity.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Bathing.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Bathing.md new file mode 100644 index 00000000000..f7844f95d54 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Bathing.md @@ -0,0 +1,30 @@ +# Bathing + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.bathing import Bathing + +# TODO update the JSON string below +json = "{}" +# create an instance of Bathing from a JSON string +bathing_instance = Bathing.from_json(json) +# print the JSON string representation of the object +print Bathing.to_json() + +# convert the object into a dict +bathing_dict = bathing_instance.to_dict() +# create an instance of Bathing from a dict +bathing_form_dict = bathing.from_dict(bathing_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/Feeding.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Feeding.md new file mode 100644 index 00000000000..30750a67a07 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Feeding.md @@ -0,0 +1,30 @@ +# Feeding + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.feeding import Feeding + +# TODO update the JSON string below +json = "{}" +# create an instance of Feeding from a JSON string +feeding_instance = Feeding.from_json(json) +# print the JSON string representation of the object +print Feeding.to_json() + +# convert the object into a dict +feeding_dict = feeding_instance.to_dict() +# create an instance of Feeding from a dict +feeding_form_dict = feeding.from_dict(feeding_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/PoopCleaning.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PoopCleaning.md new file mode 100644 index 00000000000..bbc93c0203c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/PoopCleaning.md @@ -0,0 +1,30 @@ +# PoopCleaning + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.poop_cleaning import PoopCleaning + +# TODO update the JSON string below +json = "{}" +# create an instance of PoopCleaning from a JSON string +poop_cleaning_instance = PoopCleaning.from_json(json) +# print the JSON string representation of the object +print PoopCleaning.to_json() + +# convert the object into a dict +poop_cleaning_dict = poop_cleaning_instance.to_dict() +# create an instance of PoopCleaning from a dict +poop_cleaning_form_dict = poop_cleaning.from_dict(poop_cleaning_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/Task.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Task.md new file mode 100644 index 00000000000..aefe66e7638 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/Task.md @@ -0,0 +1,30 @@ +# Task + +Used to test oneOf enums with only one string value. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | | +**activity** | [**TaskActivity**](TaskActivity.md) | | + +## Example + +```python +from petstore_api.models.task import Task + +# TODO update the JSON string below +json = "{}" +# create an instance of Task from a JSON string +task_instance = Task.from_json(json) +# print the JSON string representation of the object +print Task.to_json() + +# convert the object into a dict +task_dict = task_instance.to_dict() +# create an instance of Task from a dict +task_form_dict = task.from_dict(task_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/TaskActivity.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TaskActivity.md new file mode 100644 index 00000000000..eb254906156 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TaskActivity.md @@ -0,0 +1,30 @@ +# TaskActivity + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.task_activity import TaskActivity + +# TODO update the JSON string below +json = "{}" +# create an instance of TaskActivity from a JSON string +task_activity_instance = TaskActivity.from_json(json) +# print the JSON string representation of the object +print TaskActivity.to_json() + +# convert the object into a dict +task_activity_dict = task_activity_instance.to_dict() +# create an instance of TaskActivity from a dict +task_activity_form_dict = task_activity.from_dict(task_activity_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py index 72d39b9c55e..a0cbcf6fe0c 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 @@ -52,6 +52,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -70,6 +71,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -104,6 +106,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -113,6 +116,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 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 c106409daa9..baa94da3a2c 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 @@ -28,6 +28,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -46,6 +47,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -80,6 +82,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -89,6 +92,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/bathing.py new file mode 100644 index 00000000000..986de06f0c2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/bathing.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + 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, Field, StrictStr, validator + +class Bathing(BaseModel): + """ + Bathing + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning_deep'): + raise ValueError("must be one of enum values ('cleaning_deep')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care_nourish'): + raise ValueError("must be one of enum values ('care_nourish')") + 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) -> Bathing: + """Create an instance of Bathing 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) -> Bathing: + """Create an instance of Bathing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Bathing.parse_obj(obj) + + _obj = Bathing.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/feeding.py new file mode 100644 index 00000000000..ad8143b457a --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/feeding.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + 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, Field, StrictStr, validator + +class Feeding(BaseModel): + """ + Feeding + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning'): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care_nourish'): + raise ValueError("must be one of enum values ('care_nourish')") + 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) -> Feeding: + """Create an instance of Feeding 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) -> Feeding: + """Create an instance of Feeding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Feeding.parse_obj(obj) + + _obj = Feeding.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/poop_cleaning.py new file mode 100644 index 00000000000..54dff6de1f1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/poop_cleaning.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + 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, Field, StrictStr, validator + +class PoopCleaning(BaseModel): + """ + PoopCleaning + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning'): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care'): + raise ValueError("must be one of enum values ('care')") + 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) -> PoopCleaning: + """Create an instance of PoopCleaning 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) -> PoopCleaning: + """Create an instance of PoopCleaning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PoopCleaning.parse_obj(obj) + + _obj = PoopCleaning.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task.py new file mode 100644 index 00000000000..2fb988a0a5d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task.py @@ -0,0 +1,77 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + 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, Field, StrictStr +from petstore_api.models.task_activity import TaskActivity + +class Task(BaseModel): + """ + Used to test oneOf enums with only one string value. # noqa: E501 + """ + id: StrictStr = Field(...) + activity: TaskActivity = Field(...) + __properties = ["id", "activity"] + + 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) -> Task: + """Create an instance of Task from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of activity + if self.activity: + _dict['activity'] = self.activity.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Task: + """Create an instance of Task from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Task.parse_obj(obj) + + _obj = Task.parse_obj({ + "id": obj.get("id"), + "activity": TaskActivity.from_dict(obj.get("activity")) if obj.get("activity") is not None else None + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task_activity.py new file mode 100644 index 00000000000..70553f1ef20 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/task_activity.py @@ -0,0 +1,155 @@ +# 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 +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from petstore_api.models.bathing import Bathing +from petstore_api.models.feeding import Feeding +from petstore_api.models.poop_cleaning import PoopCleaning +from typing import Union, Any, List, TYPE_CHECKING +from pydantic import StrictStr, Field + +TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + +class TaskActivity(BaseModel): + """ + TaskActivity + """ + # data type: PoopCleaning + oneof_schema_1_validator: Optional[PoopCleaning] = None + # data type: Feeding + oneof_schema_2_validator: Optional[Feeding] = None + # data type: Bathing + oneof_schema_3_validator: Optional[Bathing] = None + if TYPE_CHECKING: + actual_instance: Union[Bathing, Feeding, PoopCleaning] + else: + actual_instance: Any + one_of_schemas: List[str] = Field(TASKACTIVITY_ONE_OF_SCHEMAS, const=True) + + class Config: + validate_assignment = True + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = TaskActivity.construct() + error_messages = [] + match = 0 + # validate data type: PoopCleaning + if not isinstance(v, PoopCleaning): + error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") + else: + match += 1 + # validate data type: Feeding + if not isinstance(v, Feeding): + error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") + else: + match += 1 + # validate data type: Bathing + if not isinstance(v, Bathing): + error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> TaskActivity: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> TaskActivity: + """Returns the object represented by the json string""" + instance = TaskActivity.construct() + error_messages = [] + match = 0 + + # deserialize data into PoopCleaning + try: + instance.actual_instance = PoopCleaning.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Feeding + try: + instance.actual_instance = Feeding.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Bathing + try: + instance.actual_instance = Bathing.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_bathing.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_bathing.py new file mode 100644 index 00000000000..cc3a79b6f41 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_bathing.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.bathing import Bathing # noqa: E501 + +class TestBathing(unittest.TestCase): + """Bathing unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Bathing: + """Test Bathing + 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 `Bathing` + """ + model = Bathing() # noqa: E501 + if include_optional: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testBathing(self): + """Test Bathing""" + # 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_feeding.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_feeding.py new file mode 100644 index 00000000000..f445dc67c1b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_feeding.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.feeding import Feeding # noqa: E501 + +class TestFeeding(unittest.TestCase): + """Feeding unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Feeding: + """Test Feeding + 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 `Feeding` + """ + model = Feeding() # noqa: E501 + if include_optional: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '' + ) + else: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '', + ) + """ + + def testFeeding(self): + """Test Feeding""" + # 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_poop_cleaning.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_poop_cleaning.py new file mode 100644 index 00000000000..e2594e920fa --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_poop_cleaning.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.poop_cleaning import PoopCleaning # noqa: E501 + +class TestPoopCleaning(unittest.TestCase): + """PoopCleaning unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PoopCleaning: + """Test PoopCleaning + 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 `PoopCleaning` + """ + model = PoopCleaning() # noqa: E501 + if include_optional: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '' + ) + else: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '', + ) + """ + + def testPoopCleaning(self): + """Test PoopCleaning""" + # 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_task.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task.py new file mode 100644 index 00000000000..8e510333d7d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.task import Task # noqa: E501 + +class TestTask(unittest.TestCase): + """Task unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Task: + """Test Task + 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 `Task` + """ + model = Task() # noqa: E501 + if include_optional: + return Task( + id = '', + activity = None + ) + else: + return Task( + id = '', + activity = None, + ) + """ + + def testTask(self): + """Test Task""" + # 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_task_activity.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task_activity.py new file mode 100644 index 00000000000..b09dc360824 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_task_activity.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.task_activity import TaskActivity # noqa: E501 + +class TestTaskActivity(unittest.TestCase): + """TaskActivity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TaskActivity: + """Test TaskActivity + 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 `TaskActivity` + """ + model = TaskActivity() # noqa: E501 + if include_optional: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testTaskActivity(self): + """Test TaskActivity""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES index 1ef5f596fa1..b03e397c14c 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -18,6 +18,7 @@ docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BasquePig.md +docs/Bathing.md docs/Capitalization.md docs/Cat.md docs/Category.md @@ -39,6 +40,7 @@ docs/EnumString2.md docs/EnumTest.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/Feeding.md docs/File.md docs/FileSchemaTestClass.md docs/FirstRef.md @@ -74,6 +76,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PoopCleaning.md docs/PropertyNameCollision.md docs/ReadOnlyFirst.md docs/SecondRef.md @@ -84,6 +87,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Task.md +docs/TaskActivity.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -122,6 +127,7 @@ petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/basque_pig.py +petstore_api/models/bathing.py petstore_api/models/capitalization.py petstore_api/models/cat.py petstore_api/models/category.py @@ -140,6 +146,7 @@ petstore_api/models/enum_class.py petstore_api/models/enum_string1.py petstore_api/models/enum_string2.py petstore_api/models/enum_test.py +petstore_api/models/feeding.py petstore_api/models/file.py petstore_api/models/file_schema_test_class.py petstore_api/models/first_ref.py @@ -174,6 +181,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/poop_cleaning.py petstore_api/models/property_name_collision.py petstore_api/models/read_only_first.py petstore_api/models/second_ref.py @@ -183,6 +191,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/task.py +petstore_api/models/task_activity.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 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 3cc746aa66f..ed4434cd181 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -154,6 +154,7 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BasquePig](docs/BasquePig.md) + - [Bathing](docs/Bathing.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) @@ -172,6 +173,7 @@ Class | Method | HTTP request | Description - [EnumString1](docs/EnumString1.md) - [EnumString2](docs/EnumString2.md) - [EnumTest](docs/EnumTest.md) + - [Feeding](docs/Feeding.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [FirstRef](docs/FirstRef.md) @@ -206,6 +208,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PoopCleaning](docs/PoopCleaning.md) - [PropertyNameCollision](docs/PropertyNameCollision.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SecondRef](docs/SecondRef.md) @@ -215,6 +218,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Task](docs/Task.md) + - [TaskActivity](docs/TaskActivity.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/Bathing.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Bathing.md new file mode 100644 index 00000000000..f7844f95d54 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Bathing.md @@ -0,0 +1,30 @@ +# Bathing + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.bathing import Bathing + +# TODO update the JSON string below +json = "{}" +# create an instance of Bathing from a JSON string +bathing_instance = Bathing.from_json(json) +# print the JSON string representation of the object +print Bathing.to_json() + +# convert the object into a dict +bathing_dict = bathing_instance.to_dict() +# create an instance of Bathing from a dict +bathing_form_dict = bathing.from_dict(bathing_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/Feeding.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Feeding.md new file mode 100644 index 00000000000..30750a67a07 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Feeding.md @@ -0,0 +1,30 @@ +# Feeding + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.feeding import Feeding + +# TODO update the JSON string below +json = "{}" +# create an instance of Feeding from a JSON string +feeding_instance = Feeding.from_json(json) +# print the JSON string representation of the object +print Feeding.to_json() + +# convert the object into a dict +feeding_dict = feeding_instance.to_dict() +# create an instance of Feeding from a dict +feeding_form_dict = feeding.from_dict(feeding_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/PoopCleaning.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/PoopCleaning.md new file mode 100644 index 00000000000..bbc93c0203c --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/PoopCleaning.md @@ -0,0 +1,30 @@ +# PoopCleaning + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.poop_cleaning import PoopCleaning + +# TODO update the JSON string below +json = "{}" +# create an instance of PoopCleaning from a JSON string +poop_cleaning_instance = PoopCleaning.from_json(json) +# print the JSON string representation of the object +print PoopCleaning.to_json() + +# convert the object into a dict +poop_cleaning_dict = poop_cleaning_instance.to_dict() +# create an instance of PoopCleaning from a dict +poop_cleaning_form_dict = poop_cleaning.from_dict(poop_cleaning_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/Task.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Task.md new file mode 100644 index 00000000000..aefe66e7638 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/Task.md @@ -0,0 +1,30 @@ +# Task + +Used to test oneOf enums with only one string value. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | | +**activity** | [**TaskActivity**](TaskActivity.md) | | + +## Example + +```python +from petstore_api.models.task import Task + +# TODO update the JSON string below +json = "{}" +# create an instance of Task from a JSON string +task_instance = Task.from_json(json) +# print the JSON string representation of the object +print Task.to_json() + +# convert the object into a dict +task_dict = task_instance.to_dict() +# create an instance of Task from a dict +task_form_dict = task.from_dict(task_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/TaskActivity.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TaskActivity.md new file mode 100644 index 00000000000..eb254906156 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TaskActivity.md @@ -0,0 +1,30 @@ +# TaskActivity + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.task_activity import TaskActivity + +# TODO update the JSON string below +json = "{}" +# create an instance of TaskActivity from a JSON string +task_activity_instance = TaskActivity.from_json(json) +# print the JSON string representation of the object +print TaskActivity.to_json() + +# convert the object into a dict +task_activity_dict = task_activity_instance.to_dict() +# create an instance of TaskActivity from a dict +task_activity_form_dict = task_activity.from_dict(task_activity_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py index 72d39b9c55e..a0cbcf6fe0c 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 @@ -52,6 +52,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -70,6 +71,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -104,6 +106,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -113,6 +116,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 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 c106409daa9..baa94da3a2c 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 @@ -28,6 +28,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -46,6 +47,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -80,6 +82,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -89,6 +92,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/bathing.py new file mode 100644 index 00000000000..09bb3b7a038 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/bathing.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 typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr, validator + +class Bathing(BaseModel): + """ + Bathing + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning_deep'): + raise ValueError("must be one of enum values ('cleaning_deep')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care_nourish'): + raise ValueError("must be one of enum values ('care_nourish')") + 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) -> Bathing: + """Create an instance of Bathing 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) -> Bathing: + """Create an instance of Bathing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Bathing.parse_obj(obj) + + _obj = Bathing.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/feeding.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/feeding.py new file mode 100644 index 00000000000..9afe7dce1b4 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/feeding.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 typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr, validator + +class Feeding(BaseModel): + """ + Feeding + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning'): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care_nourish'): + raise ValueError("must be one of enum values ('care_nourish')") + 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) -> Feeding: + """Create an instance of Feeding 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) -> Feeding: + """Create an instance of Feeding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Feeding.parse_obj(obj) + + _obj = Feeding.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/poop_cleaning.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/poop_cleaning.py new file mode 100644 index 00000000000..5649822e4f2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/poop_cleaning.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 typing import Any, Dict +from pydantic import BaseModel, Field, StrictStr, validator + +class PoopCleaning(BaseModel): + """ + PoopCleaning + """ + task_name: StrictStr = Field(...) + function_name: StrictStr = Field(...) + content: StrictStr = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["task_name", "function_name", "content"] + + @validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('cleaning'): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in ('care'): + raise ValueError("must be one of enum values ('care')") + 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) -> PoopCleaning: + """Create an instance of PoopCleaning 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) -> PoopCleaning: + """Create an instance of PoopCleaning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return PoopCleaning.parse_obj(obj) + + _obj = PoopCleaning.parse_obj({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/task.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task.py new file mode 100644 index 00000000000..3bcc9d0c3f2 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + 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 +from pydantic import BaseModel, Field, StrictStr +from petstore_api.models.task_activity import TaskActivity + +class Task(BaseModel): + """ + Used to test oneOf enums with only one string value. # noqa: E501 + """ + id: StrictStr = Field(...) + activity: TaskActivity = Field(...) + additional_properties: Dict[str, Any] = {} + __properties = ["id", "activity"] + + 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) -> Task: + """Create an instance of Task from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of activity + if self.activity: + _dict['activity'] = self.activity.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> Task: + """Create an instance of Task from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return Task.parse_obj(obj) + + _obj = Task.parse_obj({ + "id": obj.get("id"), + "activity": TaskActivity.from_dict(obj.get("activity")) if obj.get("activity") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task_activity.py new file mode 100644 index 00000000000..70553f1ef20 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/task_activity.py @@ -0,0 +1,155 @@ +# 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 +from inspect import getfullargspec +import json +import pprint +import re # noqa: F401 + +from typing import Any, List, Optional +from pydantic import BaseModel, Field, StrictStr, ValidationError, validator +from petstore_api.models.bathing import Bathing +from petstore_api.models.feeding import Feeding +from petstore_api.models.poop_cleaning import PoopCleaning +from typing import Union, Any, List, TYPE_CHECKING +from pydantic import StrictStr, Field + +TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + +class TaskActivity(BaseModel): + """ + TaskActivity + """ + # data type: PoopCleaning + oneof_schema_1_validator: Optional[PoopCleaning] = None + # data type: Feeding + oneof_schema_2_validator: Optional[Feeding] = None + # data type: Bathing + oneof_schema_3_validator: Optional[Bathing] = None + if TYPE_CHECKING: + actual_instance: Union[Bathing, Feeding, PoopCleaning] + else: + actual_instance: Any + one_of_schemas: List[str] = Field(TASKACTIVITY_ONE_OF_SCHEMAS, const=True) + + class Config: + validate_assignment = True + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = TaskActivity.construct() + error_messages = [] + match = 0 + # validate data type: PoopCleaning + if not isinstance(v, PoopCleaning): + error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") + else: + match += 1 + # validate data type: Feeding + if not isinstance(v, Feeding): + error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") + else: + match += 1 + # validate data type: Bathing + if not isinstance(v, Bathing): + error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: dict) -> TaskActivity: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> TaskActivity: + """Returns the object represented by the json string""" + instance = TaskActivity.construct() + error_messages = [] + match = 0 + + # deserialize data into PoopCleaning + try: + instance.actual_instance = PoopCleaning.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Feeding + try: + instance.actual_instance = Feeding.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Bathing + try: + instance.actual_instance = Bathing.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + to_json = getattr(self.actual_instance, "to_json", None) + if callable(to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> dict: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + to_dict = getattr(self.actual_instance, "to_dict", None) + if callable(to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.dict()) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_bathing.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_bathing.py new file mode 100644 index 00000000000..cc3a79b6f41 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_bathing.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.bathing import Bathing # noqa: E501 + +class TestBathing(unittest.TestCase): + """Bathing unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Bathing: + """Test Bathing + 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 `Bathing` + """ + model = Bathing() # noqa: E501 + if include_optional: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testBathing(self): + """Test Bathing""" + # 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_feeding.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_feeding.py new file mode 100644 index 00000000000..f445dc67c1b --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_feeding.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.feeding import Feeding # noqa: E501 + +class TestFeeding(unittest.TestCase): + """Feeding unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Feeding: + """Test Feeding + 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 `Feeding` + """ + model = Feeding() # noqa: E501 + if include_optional: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '' + ) + else: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '', + ) + """ + + def testFeeding(self): + """Test Feeding""" + # 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_poop_cleaning.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_poop_cleaning.py new file mode 100644 index 00000000000..e2594e920fa --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_poop_cleaning.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.poop_cleaning import PoopCleaning # noqa: E501 + +class TestPoopCleaning(unittest.TestCase): + """PoopCleaning unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PoopCleaning: + """Test PoopCleaning + 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 `PoopCleaning` + """ + model = PoopCleaning() # noqa: E501 + if include_optional: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '' + ) + else: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '', + ) + """ + + def testPoopCleaning(self): + """Test PoopCleaning""" + # 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_task.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_task.py new file mode 100644 index 00000000000..8e510333d7d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_task.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.task import Task # noqa: E501 + +class TestTask(unittest.TestCase): + """Task unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Task: + """Test Task + 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 `Task` + """ + model = Task() # noqa: E501 + if include_optional: + return Task( + id = '', + activity = None + ) + else: + return Task( + id = '', + activity = None, + ) + """ + + def testTask(self): + """Test Task""" + # 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_task_activity.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_task_activity.py new file mode 100644 index 00000000000..b09dc360824 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_task_activity.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.task_activity import TaskActivity # noqa: E501 + +class TestTaskActivity(unittest.TestCase): + """TaskActivity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TaskActivity: + """Test TaskActivity + 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 `TaskActivity` + """ + model = TaskActivity() # noqa: E501 + if include_optional: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testTaskActivity(self): + """Test TaskActivity""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index b85011e9790..b262850d70c 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -17,6 +17,7 @@ docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md docs/ArrayTest.md docs/BasquePig.md +docs/Bathing.md docs/Capitalization.md docs/Cat.md docs/Category.md @@ -38,6 +39,7 @@ docs/EnumString2.md docs/EnumTest.md docs/FakeApi.md docs/FakeClassnameTags123Api.md +docs/Feeding.md docs/File.md docs/FileSchemaTestClass.md docs/FirstRef.md @@ -74,6 +76,7 @@ docs/ParentWithOptionalDict.md docs/Pet.md docs/PetApi.md docs/Pig.md +docs/PoopCleaning.md docs/PropertyNameCollision.md docs/ReadOnlyFirst.md docs/SecondRef.md @@ -84,6 +87,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/Task.md +docs/TaskActivity.md docs/TestErrorResponsesWithModel400Response.md docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -121,6 +126,7 @@ petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py petstore_api/models/array_test.py petstore_api/models/basque_pig.py +petstore_api/models/bathing.py petstore_api/models/capitalization.py petstore_api/models/cat.py petstore_api/models/category.py @@ -139,6 +145,7 @@ petstore_api/models/enum_class.py petstore_api/models/enum_string1.py petstore_api/models/enum_string2.py petstore_api/models/enum_test.py +petstore_api/models/feeding.py petstore_api/models/file.py petstore_api/models/file_schema_test_class.py petstore_api/models/first_ref.py @@ -174,6 +181,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/poop_cleaning.py petstore_api/models/property_name_collision.py petstore_api/models/read_only_first.py petstore_api/models/second_ref.py @@ -183,6 +191,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/task.py +petstore_api/models/task_activity.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 diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 07f3cb8623c..605c380c809 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -152,6 +152,7 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [ArrayTest](docs/ArrayTest.md) - [BasquePig](docs/BasquePig.md) + - [Bathing](docs/Bathing.md) - [Capitalization](docs/Capitalization.md) - [Cat](docs/Cat.md) - [Category](docs/Category.md) @@ -170,6 +171,7 @@ Class | Method | HTTP request | Description - [EnumString1](docs/EnumString1.md) - [EnumString2](docs/EnumString2.md) - [EnumTest](docs/EnumTest.md) + - [Feeding](docs/Feeding.md) - [File](docs/File.md) - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - [FirstRef](docs/FirstRef.md) @@ -205,6 +207,7 @@ Class | Method | HTTP request | Description - [ParentWithOptionalDict](docs/ParentWithOptionalDict.md) - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) + - [PoopCleaning](docs/PoopCleaning.md) - [PropertyNameCollision](docs/PropertyNameCollision.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [SecondRef](docs/SecondRef.md) @@ -214,6 +217,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [Task](docs/Task.md) + - [TaskActivity](docs/TaskActivity.md) - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) diff --git a/samples/openapi3/client/petstore/python/docs/Bathing.md b/samples/openapi3/client/petstore/python/docs/Bathing.md new file mode 100644 index 00000000000..4c4963bf593 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Bathing.md @@ -0,0 +1,31 @@ +# Bathing + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.bathing import Bathing + +# TODO update the JSON string below +json = "{}" +# create an instance of Bathing from a JSON string +bathing_instance = Bathing.from_json(json) +# print the JSON string representation of the object +print Bathing.to_json() + +# convert the object into a dict +bathing_dict = bathing_instance.to_dict() +# create an instance of Bathing from a dict +bathing_form_dict = bathing.from_dict(bathing_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/Feeding.md b/samples/openapi3/client/petstore/python/docs/Feeding.md new file mode 100644 index 00000000000..f0d51f621c2 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Feeding.md @@ -0,0 +1,31 @@ +# Feeding + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.feeding import Feeding + +# TODO update the JSON string below +json = "{}" +# create an instance of Feeding from a JSON string +feeding_instance = Feeding.from_json(json) +# print the JSON string representation of the object +print Feeding.to_json() + +# convert the object into a dict +feeding_dict = feeding_instance.to_dict() +# create an instance of Feeding from a dict +feeding_form_dict = feeding.from_dict(feeding_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/PoopCleaning.md b/samples/openapi3/client/petstore/python/docs/PoopCleaning.md new file mode 100644 index 00000000000..9fd6b0c3245 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/PoopCleaning.md @@ -0,0 +1,31 @@ +# PoopCleaning + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.poop_cleaning import PoopCleaning + +# TODO update the JSON string below +json = "{}" +# create an instance of PoopCleaning from a JSON string +poop_cleaning_instance = PoopCleaning.from_json(json) +# print the JSON string representation of the object +print PoopCleaning.to_json() + +# convert the object into a dict +poop_cleaning_dict = poop_cleaning_instance.to_dict() +# create an instance of PoopCleaning from a dict +poop_cleaning_form_dict = poop_cleaning.from_dict(poop_cleaning_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/Task.md b/samples/openapi3/client/petstore/python/docs/Task.md new file mode 100644 index 00000000000..6cee08c6fe6 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/Task.md @@ -0,0 +1,31 @@ +# Task + +Used to test oneOf enums with only one string value. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | | +**activity** | [**TaskActivity**](TaskActivity.md) | | + +## Example + +```python +from petstore_api.models.task import Task + +# TODO update the JSON string below +json = "{}" +# create an instance of Task from a JSON string +task_instance = Task.from_json(json) +# print the JSON string representation of the object +print Task.to_json() + +# convert the object into a dict +task_dict = task_instance.to_dict() +# create an instance of Task from a dict +task_form_dict = task.from_dict(task_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/TaskActivity.md b/samples/openapi3/client/petstore/python/docs/TaskActivity.md new file mode 100644 index 00000000000..37f10f9031e --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TaskActivity.md @@ -0,0 +1,31 @@ +# TaskActivity + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**task_name** | **str** | | +**function_name** | **str** | | +**content** | **str** | | + +## Example + +```python +from petstore_api.models.task_activity import TaskActivity + +# TODO update the JSON string below +json = "{}" +# create an instance of TaskActivity from a JSON string +task_activity_instance = TaskActivity.from_json(json) +# print the JSON string representation of the object +print TaskActivity.to_json() + +# convert the object into a dict +task_activity_dict = task_activity_instance.to_dict() +# create an instance of TaskActivity from a dict +task_activity_form_dict = task_activity.from_dict(task_activity_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index f791bc53112..704dcbaffbd 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -51,6 +51,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -69,6 +70,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -104,6 +106,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -113,6 +116,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 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 945dd198de1..554f557cb05 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -27,6 +27,7 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb from petstore_api.models.array_of_number_only import ArrayOfNumberOnly from petstore_api.models.array_test import ArrayTest from petstore_api.models.basque_pig import BasquePig +from petstore_api.models.bathing import Bathing from petstore_api.models.capitalization import Capitalization from petstore_api.models.cat import Cat from petstore_api.models.category import Category @@ -45,6 +46,7 @@ from petstore_api.models.enum_class import EnumClass from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 from petstore_api.models.enum_test import EnumTest +from petstore_api.models.feeding import Feeding from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.first_ref import FirstRef @@ -80,6 +82,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.poop_cleaning import PoopCleaning from petstore_api.models.property_name_collision import PropertyNameCollision from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.second_ref import SecondRef @@ -89,6 +92,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.task import Task +from petstore_api.models.task_activity import TaskActivity 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 diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py new file mode 100644 index 00000000000..7ea7084ae9d --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -0,0 +1,118 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Bathing(BaseModel): + """ + Bathing + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning_deep']): + raise ValueError("must be one of enum values ('cleaning_deep')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care_nourish']): + raise ValueError("must be one of enum values ('care_nourish')") + return value + + model_config = { + "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 Bathing 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 Bathing from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index 378abbf93c6..bd46be86ea6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -37,7 +37,7 @@ class EnumArrays(BaseModel): if value is None: return value - if value not in ('>=', '$'): + if value not in set(['>=', '$']): raise ValueError("must be one of enum values ('>=', '$')") return value @@ -48,7 +48,7 @@ class EnumArrays(BaseModel): return value for i in value: - if i not in ('fish', 'crab'): + if i not in set(['fish', 'crab']): raise ValueError("each list item must be one of ('fish', 'crab')") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 835d3da2330..a3d6f6fc9cc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -48,14 +48,14 @@ class EnumTest(BaseModel): if value is None: return value - if value not in ('UPPER', 'lower', ''): + if value not in set(['UPPER', 'lower', '']): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value @field_validator('enum_string_required') def enum_string_required_validate_enum(cls, value): """Validates the enum""" - if value not in ('UPPER', 'lower', ''): + if value not in set(['UPPER', 'lower', '']): raise ValueError("must be one of enum values ('UPPER', 'lower', '')") return value @@ -65,7 +65,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1, 5, 14): + if value not in set([1, 5, 14]): raise ValueError("must be one of enum values (1, 5, 14)") return value @@ -75,7 +75,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1, -1): + if value not in set([1, -1]): raise ValueError("must be one of enum values (1, -1)") return value @@ -85,7 +85,7 @@ class EnumTest(BaseModel): if value is None: return value - if value not in (1.1, -1.2): + if value not in set([1.1, -1.2]): raise ValueError("must be one of enum values (1.1, -1.2)") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py new file mode 100644 index 00000000000..e09b83a21b0 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -0,0 +1,118 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Feeding(BaseModel): + """ + Feeding + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning']): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care_nourish']): + raise ValueError("must be one of enum values ('care_nourish')") + return value + + model_config = { + "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 Feeding 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 Feeding from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 3912fd9d66e..711379c0f16 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -39,7 +39,7 @@ class MapTest(BaseModel): if value is None: return value - if value not in ('UPPER', 'lower'): + if value not in set(['UPPER', 'lower']): raise ValueError("must be one of enum values ('UPPER', 'lower')") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index d9fa3d4e2f3..19a829bd92d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -42,7 +42,7 @@ class Order(BaseModel): if value is None: return value - if value not in ('placed', 'approved', 'delivered'): + if value not in set(['placed', 'approved', 'delivered']): raise ValueError("must be one of enum values ('placed', 'approved', 'delivered')") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index fe2bf02c789..eca4a98dcc9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -44,7 +44,7 @@ class Pet(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py new file mode 100644 index 00000000000..7d881efcd21 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -0,0 +1,118 @@ +# 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, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class PoopCleaning(BaseModel): + """ + PoopCleaning + """ # noqa: E501 + task_name: StrictStr + function_name: StrictStr + content: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] + + @field_validator('task_name') + def task_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['cleaning']): + raise ValueError("must be one of enum values ('cleaning')") + return value + + @field_validator('function_name') + def function_name_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['care']): + raise ValueError("must be one of enum values ('care')") + return value + + model_config = { + "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 PoopCleaning 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 PoopCleaning from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "task_name": obj.get("task_name"), + "function_name": obj.get("function_name"), + "content": obj.get("content") + }) + # 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/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 1322827d7eb..8ab35951c1a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -39,7 +39,7 @@ class SpecialName(BaseModel): if value is None: return value - if value not in ('available', 'pending', 'sold'): + if value not in set(['available', 'pending', 'sold']): raise ValueError("must be one of enum values ('available', 'pending', 'sold')") return value diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py new file mode 100644 index 00000000000..2a58ebaed92 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -0,0 +1,106 @@ +# 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, StrictStr +from typing import Any, ClassVar, Dict, List +from petstore_api.models.task_activity import TaskActivity +from typing import Optional, Set +from typing_extensions import Self + +class Task(BaseModel): + """ + Used to test oneOf enums with only one string value. + """ # noqa: E501 + id: StrictStr + activity: TaskActivity + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "activity"] + + model_config = { + "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 Task from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of activity + if self.activity: + _dict['activity'] = self.activity.to_dict() + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Task from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py new file mode 100644 index 00000000000..b76c2604597 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -0,0 +1,151 @@ +# 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 +import pprint +from pydantic import BaseModel, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from petstore_api.models.bathing import Bathing +from petstore_api.models.feeding import Feeding +from petstore_api.models.poop_cleaning import PoopCleaning +from pydantic import StrictStr, Field +from typing import Union, List, Optional, Dict +from typing_extensions import Literal, Self + +TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + +class TaskActivity(BaseModel): + """ + TaskActivity + """ + # data type: PoopCleaning + oneof_schema_1_validator: Optional[PoopCleaning] = None + # data type: Feeding + oneof_schema_2_validator: Optional[Feeding] = None + # data type: Bathing + oneof_schema_3_validator: Optional[Bathing] = None + actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None + one_of_schemas: List[str] = Field(default=Literal["Bathing", "Feeding", "PoopCleaning"]) + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } + + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator('actual_instance') + def actual_instance_must_validate_oneof(cls, v): + instance = TaskActivity.model_construct() + error_messages = [] + match = 0 + # validate data type: PoopCleaning + if not isinstance(v, PoopCleaning): + error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") + else: + match += 1 + # validate data type: Feeding + if not isinstance(v, Feeding): + error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") + else: + match += 1 + # validate data type: Bathing + if not isinstance(v, Bathing): + error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into PoopCleaning + try: + instance.actual_instance = PoopCleaning.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Feeding + try: + instance.actual_instance = Feeding.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into Bathing + try: + instance.actual_instance = Bathing.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) + + diff --git a/samples/openapi3/client/petstore/python/test/test_bathing.py b/samples/openapi3/client/petstore/python/test/test_bathing.py new file mode 100644 index 00000000000..583bdcbb09e --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_bathing.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.bathing import Bathing + +class TestBathing(unittest.TestCase): + """Bathing unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Bathing: + """Test Bathing + 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 `Bathing` + """ + model = Bathing() + if include_optional: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return Bathing( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testBathing(self): + """Test Bathing""" + # 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_feeding.py b/samples/openapi3/client/petstore/python/test/test_feeding.py new file mode 100644 index 00000000000..a0cdfc8f346 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_feeding.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.feeding import Feeding + +class TestFeeding(unittest.TestCase): + """Feeding unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Feeding: + """Test Feeding + 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 `Feeding` + """ + model = Feeding() + if include_optional: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '' + ) + else: + return Feeding( + task_name = 'cleaning', + function_name = 'care_nourish', + content = '', + ) + """ + + def testFeeding(self): + """Test Feeding""" + # 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_poop_cleaning.py b/samples/openapi3/client/petstore/python/test/test_poop_cleaning.py new file mode 100644 index 00000000000..4c94fddca97 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_poop_cleaning.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.poop_cleaning import PoopCleaning + +class TestPoopCleaning(unittest.TestCase): + """PoopCleaning unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PoopCleaning: + """Test PoopCleaning + 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 `PoopCleaning` + """ + model = PoopCleaning() + if include_optional: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '' + ) + else: + return PoopCleaning( + task_name = 'cleaning', + function_name = 'care', + content = '', + ) + """ + + def testPoopCleaning(self): + """Test PoopCleaning""" + # 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_task.py b/samples/openapi3/client/petstore/python/test/test_task.py new file mode 100644 index 00000000000..bbbc14a3992 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_task.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.task import Task + +class TestTask(unittest.TestCase): + """Task unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> Task: + """Test Task + 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 `Task` + """ + model = Task() + if include_optional: + return Task( + id = '', + activity = None + ) + else: + return Task( + id = '', + activity = None, + ) + """ + + def testTask(self): + """Test Task""" + # 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_task_activity.py b/samples/openapi3/client/petstore/python/test/test_task_activity.py new file mode 100644 index 00000000000..2d56d9c5ad3 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_task_activity.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.task_activity import TaskActivity + +class TestTaskActivity(unittest.TestCase): + """TaskActivity unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TaskActivity: + """Test TaskActivity + 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 `TaskActivity` + """ + model = TaskActivity() + if include_optional: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '' + ) + else: + return TaskActivity( + task_name = 'cleaning_deep', + function_name = 'care_nourish', + content = '', + ) + """ + + def testTaskActivity(self): + """Test TaskActivity""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()