forked from loafle/openapi-generator-original
Add enum default value tests to python clients (#18883)
* add enum default value tests to python clients * add new files
This commit is contained in:
parent
a5a99585ef
commit
0cc9644120
@ -2792,4 +2792,41 @@ components:
|
||||
- properties:
|
||||
_value:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
TestEnum:
|
||||
type: string
|
||||
enum:
|
||||
- ONE
|
||||
- TWO
|
||||
- THREE
|
||||
- foUr
|
||||
TestEnumWithDefault:
|
||||
type: string
|
||||
enum:
|
||||
- EIN
|
||||
- ZWEI
|
||||
- DREI
|
||||
default: ZWEI
|
||||
TestModelWithEnumDefault:
|
||||
type: object
|
||||
required:
|
||||
- test_enum
|
||||
properties:
|
||||
test_enum:
|
||||
$ref: "#/components/schemas/TestEnum"
|
||||
test_string:
|
||||
type: string
|
||||
example: "Just some string"
|
||||
test_enum_with_default:
|
||||
$ref: "#/components/schemas/TestEnumWithDefault"
|
||||
test_string_with_default:
|
||||
type: string
|
||||
example: "More string"
|
||||
default: "ahoy matey"
|
||||
test_inline_defined_enum_with_default:
|
||||
type: string
|
||||
enum:
|
||||
- A
|
||||
- B
|
||||
- C
|
||||
default: B
|
||||
|
@ -101,9 +101,12 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/Task.md
|
||||
docs/TaskActivity.md
|
||||
docs/TestEnum.md
|
||||
docs/TestEnumWithDefault.md
|
||||
docs/TestErrorResponsesWithModel400Response.md
|
||||
docs/TestErrorResponsesWithModel404Response.md
|
||||
docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
@ -218,9 +221,12 @@ petstore_api/models/special_name.py
|
||||
petstore_api/models/tag.py
|
||||
petstore_api/models/task.py
|
||||
petstore_api/models/task_activity.py
|
||||
petstore_api/models/test_enum.py
|
||||
petstore_api/models/test_enum_with_default.py
|
||||
petstore_api/models/test_error_responses_with_model400_response.py
|
||||
petstore_api/models/test_error_responses_with_model404_response.py
|
||||
petstore_api/models/test_inline_freeform_additional_properties_request.py
|
||||
petstore_api/models/test_model_with_enum_default.py
|
||||
petstore_api/models/test_object_for_multipart_requests_request_marker.py
|
||||
petstore_api/models/tiger.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
|
@ -241,9 +241,12 @@ Class | Method | HTTP request | Description
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Task](docs/Task.md)
|
||||
- [TaskActivity](docs/TaskActivity.md)
|
||||
- [TestEnum](docs/TestEnum.md)
|
||||
- [TestEnumWithDefault](docs/TestEnumWithDefault.md)
|
||||
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
|
||||
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
|
||||
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# TestEnum
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `ONE` (value: `'ONE'`)
|
||||
|
||||
* `TWO` (value: `'TWO'`)
|
||||
|
||||
* `THREE` (value: `'THREE'`)
|
||||
|
||||
* `FOUR` (value: `'foUr'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# TestEnumWithDefault
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `EIN` (value: `'EIN'`)
|
||||
|
||||
* `ZWEI` (value: `'ZWEI'`)
|
||||
|
||||
* `DREI` (value: `'DREI'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
# TestModelWithEnumDefault
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**test_enum** | [**TestEnum**](TestEnum.md) | |
|
||||
**test_string** | **str** | | [optional]
|
||||
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] [default to TestEnumWithDefault.ZWEI]
|
||||
**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey']
|
||||
**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B']
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of TestModelWithEnumDefault from a JSON string
|
||||
test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print(TestModelWithEnumDefault.to_json())
|
||||
|
||||
# convert the object into a dict
|
||||
test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict()
|
||||
# create an instance of TestModelWithEnumDefault from a dict
|
||||
test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -130,9 +130,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -105,9 +105,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -0,0 +1,39 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class TestEnum(str, Enum):
|
||||
"""
|
||||
TestEnum
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
ONE = 'ONE'
|
||||
TWO = 'TWO'
|
||||
THREE = 'THREE'
|
||||
FOUR = 'foUr'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of TestEnum from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class TestEnumWithDefault(str, Enum):
|
||||
"""
|
||||
TestEnumWithDefault
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
EIN = 'EIN'
|
||||
ZWEI = 'ZWEI'
|
||||
DREI = 'DREI'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of TestEnumWithDefault from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,107 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestModelWithEnumDefault(BaseModel):
|
||||
"""
|
||||
TestModelWithEnumDefault
|
||||
""" # noqa: E501
|
||||
test_enum: TestEnum
|
||||
test_string: Optional[StrictStr] = None
|
||||
test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI
|
||||
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
|
||||
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
|
||||
__properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
|
||||
|
||||
@field_validator('test_inline_defined_enum_with_default')
|
||||
def test_inline_defined_enum_with_default_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['A', 'B', 'C']):
|
||||
raise ValueError("must be one of enum values ('A', 'B', 'C')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestModelWithEnumDefault from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of TestModelWithEnumDefault from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"test_enum": obj.get("test_enum"),
|
||||
"test_string": obj.get("test_string"),
|
||||
"test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI,
|
||||
"test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey',
|
||||
"test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B'
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
|
||||
class TestTestEnum(unittest.TestCase):
|
||||
"""TestEnum unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnum(self):
|
||||
"""Test TestEnum"""
|
||||
# inst = TestEnum()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
|
||||
class TestTestEnumWithDefault(unittest.TestCase):
|
||||
"""TestEnumWithDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnumWithDefault(self):
|
||||
"""Test TestEnumWithDefault"""
|
||||
# inst = TestEnumWithDefault()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,56 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
class TestTestModelWithEnumDefault(unittest.TestCase):
|
||||
"""TestModelWithEnumDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> TestModelWithEnumDefault:
|
||||
"""Test TestModelWithEnumDefault
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `TestModelWithEnumDefault`
|
||||
"""
|
||||
model = TestModelWithEnumDefault()
|
||||
if include_optional:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
test_string = 'Just some string',
|
||||
test_enum_with_default = 'ZWEI',
|
||||
test_string_with_default = 'ahoy matey',
|
||||
test_inline_defined_enum_with_default = 'B'
|
||||
)
|
||||
else:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
)
|
||||
"""
|
||||
|
||||
def testTestModelWithEnumDefault(self):
|
||||
"""Test TestModelWithEnumDefault"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -101,9 +101,12 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/Task.md
|
||||
docs/TaskActivity.md
|
||||
docs/TestEnum.md
|
||||
docs/TestEnumWithDefault.md
|
||||
docs/TestErrorResponsesWithModel400Response.md
|
||||
docs/TestErrorResponsesWithModel404Response.md
|
||||
docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
@ -218,9 +221,12 @@ petstore_api/models/special_name.py
|
||||
petstore_api/models/tag.py
|
||||
petstore_api/models/task.py
|
||||
petstore_api/models/task_activity.py
|
||||
petstore_api/models/test_enum.py
|
||||
petstore_api/models/test_enum_with_default.py
|
||||
petstore_api/models/test_error_responses_with_model400_response.py
|
||||
petstore_api/models/test_error_responses_with_model404_response.py
|
||||
petstore_api/models/test_inline_freeform_additional_properties_request.py
|
||||
petstore_api/models/test_model_with_enum_default.py
|
||||
petstore_api/models/test_object_for_multipart_requests_request_marker.py
|
||||
petstore_api/models/tiger.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
|
@ -242,9 +242,12 @@ Class | Method | HTTP request | Description
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Task](docs/Task.md)
|
||||
- [TaskActivity](docs/TaskActivity.md)
|
||||
- [TestEnum](docs/TestEnum.md)
|
||||
- [TestEnumWithDefault](docs/TestEnumWithDefault.md)
|
||||
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
|
||||
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
|
||||
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# TestEnum
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `ONE` (value: `'ONE'`)
|
||||
|
||||
* `TWO` (value: `'TWO'`)
|
||||
|
||||
* `THREE` (value: `'THREE'`)
|
||||
|
||||
* `FOUR` (value: `'foUr'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# TestEnumWithDefault
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `EIN` (value: `'EIN'`)
|
||||
|
||||
* `ZWEI` (value: `'ZWEI'`)
|
||||
|
||||
* `DREI` (value: `'DREI'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
# TestModelWithEnumDefault
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**test_enum** | [**TestEnum**](TestEnum.md) | |
|
||||
**test_string** | **str** | | [optional]
|
||||
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional]
|
||||
**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey']
|
||||
**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B']
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of TestModelWithEnumDefault from a JSON string
|
||||
test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print TestModelWithEnumDefault.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict()
|
||||
# create an instance of TestModelWithEnumDefault from a dict
|
||||
test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -130,9 +130,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -105,9 +105,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -0,0 +1,42 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from aenum import Enum, no_arg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestEnum(str, Enum):
|
||||
"""
|
||||
TestEnum
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
ONE = 'ONE'
|
||||
TWO = 'TWO'
|
||||
THREE = 'THREE'
|
||||
FOUR = 'foUr'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestEnum:
|
||||
"""Create an instance of TestEnum from a JSON string"""
|
||||
return TestEnum(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from aenum import Enum, no_arg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestEnumWithDefault(str, Enum):
|
||||
"""
|
||||
TestEnumWithDefault
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
EIN = 'EIN'
|
||||
ZWEI = 'ZWEI'
|
||||
DREI = 'DREI'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestEnumWithDefault:
|
||||
"""Create an instance of TestEnumWithDefault from a JSON string"""
|
||||
return TestEnumWithDefault(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field, StrictStr, validator
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
|
||||
class TestModelWithEnumDefault(BaseModel):
|
||||
"""
|
||||
TestModelWithEnumDefault
|
||||
"""
|
||||
test_enum: TestEnum = Field(...)
|
||||
test_string: Optional[StrictStr] = None
|
||||
test_enum_with_default: Optional[TestEnumWithDefault] = None
|
||||
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
|
||||
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
|
||||
__properties = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
|
||||
|
||||
@validator('test_inline_defined_enum_with_default')
|
||||
def test_inline_defined_enum_with_default_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in ('A', 'B', 'C'):
|
||||
raise ValueError("must be one of enum values ('A', 'B', 'C')")
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestModelWithEnumDefault:
|
||||
"""Create an instance of TestModelWithEnumDefault from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
},
|
||||
exclude_none=True)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> TestModelWithEnumDefault:
|
||||
"""Create an instance of TestModelWithEnumDefault from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return TestModelWithEnumDefault.parse_obj(obj)
|
||||
|
||||
_obj = TestModelWithEnumDefault.parse_obj({
|
||||
"test_enum": obj.get("test_enum"),
|
||||
"test_string": obj.get("test_string"),
|
||||
"test_enum_with_default": obj.get("test_enum_with_default"),
|
||||
"test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey',
|
||||
"test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B'
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_enum import TestEnum # noqa: E501
|
||||
|
||||
class TestTestEnum(unittest.TestCase):
|
||||
"""TestEnum unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnum(self):
|
||||
"""Test TestEnum"""
|
||||
# inst = TestEnum()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,34 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault # noqa: E501
|
||||
|
||||
class TestTestEnumWithDefault(unittest.TestCase):
|
||||
"""TestEnumWithDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnumWithDefault(self):
|
||||
"""Test TestEnumWithDefault"""
|
||||
# inst = TestEnumWithDefault()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault # noqa: E501
|
||||
|
||||
class TestTestModelWithEnumDefault(unittest.TestCase):
|
||||
"""TestModelWithEnumDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> TestModelWithEnumDefault:
|
||||
"""Test TestModelWithEnumDefault
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `TestModelWithEnumDefault`
|
||||
"""
|
||||
model = TestModelWithEnumDefault() # noqa: E501
|
||||
if include_optional:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
test_string = 'Just some string',
|
||||
test_enum_with_default = 'ZWEI',
|
||||
test_string_with_default = 'ahoy matey',
|
||||
test_inline_defined_enum_with_default = 'B'
|
||||
)
|
||||
else:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
)
|
||||
"""
|
||||
|
||||
def testTestModelWithEnumDefault(self):
|
||||
"""Test TestModelWithEnumDefault"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -101,9 +101,12 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/Task.md
|
||||
docs/TaskActivity.md
|
||||
docs/TestEnum.md
|
||||
docs/TestEnumWithDefault.md
|
||||
docs/TestErrorResponsesWithModel400Response.md
|
||||
docs/TestErrorResponsesWithModel404Response.md
|
||||
docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
@ -218,9 +221,12 @@ petstore_api/models/special_name.py
|
||||
petstore_api/models/tag.py
|
||||
petstore_api/models/task.py
|
||||
petstore_api/models/task_activity.py
|
||||
petstore_api/models/test_enum.py
|
||||
petstore_api/models/test_enum_with_default.py
|
||||
petstore_api/models/test_error_responses_with_model400_response.py
|
||||
petstore_api/models/test_error_responses_with_model404_response.py
|
||||
petstore_api/models/test_inline_freeform_additional_properties_request.py
|
||||
petstore_api/models/test_model_with_enum_default.py
|
||||
petstore_api/models/test_object_for_multipart_requests_request_marker.py
|
||||
petstore_api/models/tiger.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
|
@ -242,9 +242,12 @@ Class | Method | HTTP request | Description
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Task](docs/Task.md)
|
||||
- [TaskActivity](docs/TaskActivity.md)
|
||||
- [TestEnum](docs/TestEnum.md)
|
||||
- [TestEnumWithDefault](docs/TestEnumWithDefault.md)
|
||||
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
|
||||
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
|
||||
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
|
@ -0,0 +1,16 @@
|
||||
# TestEnum
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `ONE` (value: `'ONE'`)
|
||||
|
||||
* `TWO` (value: `'TWO'`)
|
||||
|
||||
* `THREE` (value: `'THREE'`)
|
||||
|
||||
* `FOUR` (value: `'foUr'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# TestEnumWithDefault
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `EIN` (value: `'EIN'`)
|
||||
|
||||
* `ZWEI` (value: `'ZWEI'`)
|
||||
|
||||
* `DREI` (value: `'DREI'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
# TestModelWithEnumDefault
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**test_enum** | [**TestEnum**](TestEnum.md) | |
|
||||
**test_string** | **str** | | [optional]
|
||||
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional]
|
||||
**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey']
|
||||
**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B']
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of TestModelWithEnumDefault from a JSON string
|
||||
test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print TestModelWithEnumDefault.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict()
|
||||
# create an instance of TestModelWithEnumDefault from a dict
|
||||
test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -130,9 +130,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -105,9 +105,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -0,0 +1,42 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from aenum import Enum, no_arg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestEnum(str, Enum):
|
||||
"""
|
||||
TestEnum
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
ONE = 'ONE'
|
||||
TWO = 'TWO'
|
||||
THREE = 'THREE'
|
||||
FOUR = 'foUr'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestEnum:
|
||||
"""Create an instance of TestEnum from a JSON string"""
|
||||
return TestEnum(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
from aenum import Enum, no_arg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TestEnumWithDefault(str, Enum):
|
||||
"""
|
||||
TestEnumWithDefault
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
EIN = 'EIN'
|
||||
ZWEI = 'ZWEI'
|
||||
DREI = 'DREI'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestEnumWithDefault:
|
||||
"""Create an instance of TestEnumWithDefault from a JSON string"""
|
||||
return TestEnumWithDefault(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
|
||||
from typing import Any, Dict, Optional
|
||||
from pydantic import BaseModel, Field, StrictStr, validator
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
|
||||
class TestModelWithEnumDefault(BaseModel):
|
||||
"""
|
||||
TestModelWithEnumDefault
|
||||
"""
|
||||
test_enum: TestEnum = Field(...)
|
||||
test_string: Optional[StrictStr] = None
|
||||
test_enum_with_default: Optional[TestEnumWithDefault] = None
|
||||
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
|
||||
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
|
||||
|
||||
@validator('test_inline_defined_enum_with_default')
|
||||
def test_inline_defined_enum_with_default_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in ('A', 'B', 'C'):
|
||||
raise ValueError("must be one of enum values ('A', 'B', 'C')")
|
||||
return value
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration"""
|
||||
allow_population_by_field_name = True
|
||||
validate_assignment = True
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.dict(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> TestModelWithEnumDefault:
|
||||
"""Create an instance of TestModelWithEnumDefault from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the dictionary representation of the model using alias"""
|
||||
_dict = self.dict(by_alias=True,
|
||||
exclude={
|
||||
"additional_properties"
|
||||
},
|
||||
exclude_none=True)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> TestModelWithEnumDefault:
|
||||
"""Create an instance of TestModelWithEnumDefault from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return TestModelWithEnumDefault.parse_obj(obj)
|
||||
|
||||
_obj = TestModelWithEnumDefault.parse_obj({
|
||||
"test_enum": obj.get("test_enum"),
|
||||
"test_string": obj.get("test_string"),
|
||||
"test_enum_with_default": obj.get("test_enum_with_default"),
|
||||
"test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey',
|
||||
"test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B'
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_enum import TestEnum # noqa: E501
|
||||
|
||||
class TestTestEnum(unittest.TestCase):
|
||||
"""TestEnum unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnum(self):
|
||||
"""Test TestEnum"""
|
||||
# inst = TestEnum()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,34 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault # noqa: E501
|
||||
|
||||
class TestTestEnumWithDefault(unittest.TestCase):
|
||||
"""TestEnumWithDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnumWithDefault(self):
|
||||
"""Test TestEnumWithDefault"""
|
||||
# inst = TestEnumWithDefault()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault # noqa: E501
|
||||
|
||||
class TestTestModelWithEnumDefault(unittest.TestCase):
|
||||
"""TestModelWithEnumDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> TestModelWithEnumDefault:
|
||||
"""Test TestModelWithEnumDefault
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `TestModelWithEnumDefault`
|
||||
"""
|
||||
model = TestModelWithEnumDefault() # noqa: E501
|
||||
if include_optional:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
test_string = 'Just some string',
|
||||
test_enum_with_default = 'ZWEI',
|
||||
test_string_with_default = 'ahoy matey',
|
||||
test_inline_defined_enum_with_default = 'B'
|
||||
)
|
||||
else:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
)
|
||||
"""
|
||||
|
||||
def testTestModelWithEnumDefault(self):
|
||||
"""Test TestModelWithEnumDefault"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -101,9 +101,12 @@ docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/Task.md
|
||||
docs/TaskActivity.md
|
||||
docs/TestEnum.md
|
||||
docs/TestEnumWithDefault.md
|
||||
docs/TestErrorResponsesWithModel400Response.md
|
||||
docs/TestErrorResponsesWithModel404Response.md
|
||||
docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
@ -218,9 +221,12 @@ petstore_api/models/special_name.py
|
||||
petstore_api/models/tag.py
|
||||
petstore_api/models/task.py
|
||||
petstore_api/models/task_activity.py
|
||||
petstore_api/models/test_enum.py
|
||||
petstore_api/models/test_enum_with_default.py
|
||||
petstore_api/models/test_error_responses_with_model400_response.py
|
||||
petstore_api/models/test_error_responses_with_model404_response.py
|
||||
petstore_api/models/test_inline_freeform_additional_properties_request.py
|
||||
petstore_api/models/test_model_with_enum_default.py
|
||||
petstore_api/models/test_object_for_multipart_requests_request_marker.py
|
||||
petstore_api/models/tiger.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
|
@ -241,9 +241,12 @@ Class | Method | HTTP request | Description
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Task](docs/Task.md)
|
||||
- [TaskActivity](docs/TaskActivity.md)
|
||||
- [TestEnum](docs/TestEnum.md)
|
||||
- [TestEnumWithDefault](docs/TestEnumWithDefault.md)
|
||||
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
|
||||
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
|
||||
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
|
16
samples/openapi3/client/petstore/python/docs/TestEnum.md
Normal file
16
samples/openapi3/client/petstore/python/docs/TestEnum.md
Normal file
@ -0,0 +1,16 @@
|
||||
# TestEnum
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `ONE` (value: `'ONE'`)
|
||||
|
||||
* `TWO` (value: `'TWO'`)
|
||||
|
||||
* `THREE` (value: `'THREE'`)
|
||||
|
||||
* `FOUR` (value: `'foUr'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
# TestEnumWithDefault
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `EIN` (value: `'EIN'`)
|
||||
|
||||
* `ZWEI` (value: `'ZWEI'`)
|
||||
|
||||
* `DREI` (value: `'DREI'`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
# TestModelWithEnumDefault
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**test_enum** | [**TestEnum**](TestEnum.md) | |
|
||||
**test_string** | **str** | | [optional]
|
||||
**test_enum_with_default** | [**TestEnumWithDefault**](TestEnumWithDefault.md) | | [optional] [default to TestEnumWithDefault.ZWEI]
|
||||
**test_string_with_default** | **str** | | [optional] [default to 'ahoy matey']
|
||||
**test_inline_defined_enum_with_default** | **str** | | [optional] [default to 'B']
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of TestModelWithEnumDefault from a JSON string
|
||||
test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print(TestModelWithEnumDefault.to_json())
|
||||
|
||||
# convert the object into a dict
|
||||
test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict()
|
||||
# create an instance of TestModelWithEnumDefault from a dict
|
||||
test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict)
|
||||
```
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -130,9 +130,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -105,9 +105,12 @@ 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_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
|
||||
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
|
||||
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
|
@ -0,0 +1,39 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class TestEnum(str, Enum):
|
||||
"""
|
||||
TestEnum
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
ONE = 'ONE'
|
||||
TWO = 'TWO'
|
||||
THREE = 'THREE'
|
||||
FOUR = 'foUr'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of TestEnum from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing_extensions import Self
|
||||
|
||||
|
||||
class TestEnumWithDefault(str, Enum):
|
||||
"""
|
||||
TestEnumWithDefault
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
EIN = 'EIN'
|
||||
ZWEI = 'ZWEI'
|
||||
DREI = 'DREI'
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of TestEnumWithDefault from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,120 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestModelWithEnumDefault(BaseModel):
|
||||
"""
|
||||
TestModelWithEnumDefault
|
||||
""" # noqa: E501
|
||||
test_enum: TestEnum
|
||||
test_string: Optional[StrictStr] = None
|
||||
test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI
|
||||
test_string_with_default: Optional[StrictStr] = 'ahoy matey'
|
||||
test_inline_defined_enum_with_default: Optional[StrictStr] = 'B'
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"]
|
||||
|
||||
@field_validator('test_inline_defined_enum_with_default')
|
||||
def test_inline_defined_enum_with_default_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['A', 'B', 'C']):
|
||||
raise ValueError("must be one of enum values ('A', 'B', 'C')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestModelWithEnumDefault from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
* Fields in `self.additional_properties` are added to the output dict.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
"additional_properties",
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
if self.additional_properties is not None:
|
||||
for _key, _value in self.additional_properties.items():
|
||||
_dict[_key] = _value
|
||||
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of TestModelWithEnumDefault from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"test_enum": obj.get("test_enum"),
|
||||
"test_string": obj.get("test_string"),
|
||||
"test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI,
|
||||
"test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey',
|
||||
"test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B'
|
||||
})
|
||||
# store additional fields in additional_properties
|
||||
for _key in obj.keys():
|
||||
if _key not in cls.__properties:
|
||||
_obj.additional_properties[_key] = obj.get(_key)
|
||||
|
||||
return _obj
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_enum import TestEnum
|
||||
|
||||
class TestTestEnum(unittest.TestCase):
|
||||
"""TestEnum unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnum(self):
|
||||
"""Test TestEnum"""
|
||||
# inst = TestEnum()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
|
||||
|
||||
class TestTestEnumWithDefault(unittest.TestCase):
|
||||
"""TestEnumWithDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testTestEnumWithDefault(self):
|
||||
"""Test TestEnumWithDefault"""
|
||||
# inst = TestEnumWithDefault()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,56 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
|
||||
|
||||
class TestTestModelWithEnumDefault(unittest.TestCase):
|
||||
"""TestModelWithEnumDefault unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> TestModelWithEnumDefault:
|
||||
"""Test TestModelWithEnumDefault
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `TestModelWithEnumDefault`
|
||||
"""
|
||||
model = TestModelWithEnumDefault()
|
||||
if include_optional:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
test_string = 'Just some string',
|
||||
test_enum_with_default = 'ZWEI',
|
||||
test_string_with_default = 'ahoy matey',
|
||||
test_inline_defined_enum_with_default = 'B'
|
||||
)
|
||||
else:
|
||||
return TestModelWithEnumDefault(
|
||||
test_enum = 'ONE',
|
||||
)
|
||||
"""
|
||||
|
||||
def testTestModelWithEnumDefault(self):
|
||||
"""Test TestModelWithEnumDefault"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user