Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions samples/openapi3/client/petstore/python-aiohttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions samples/openapi3/client/petstore/python-aiohttp/docs/TestEnum.md
Original file line number Diff line number Diff line change
@@ -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)


Original file line number Diff line number Diff line change
@@ -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)


Original file line number Diff line number Diff line change
@@ -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)


Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@
from petstore_api.models.tag import Tag
from petstore_api.models.task import Task
from petstore_api.models.task_activity import TaskActivity
from petstore_api.models.test_enum import TestEnum
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@
from petstore_api.models.tag import Tag
from petstore_api.models.task import Task
from petstore_api.models.task_activity import TaskActivity
from petstore_api.models.test_enum import TestEnum
from petstore_api.models.test_enum_with_default import TestEnumWithDefault
from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response
from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response
from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker
from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -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))


Original file line number Diff line number Diff line change
@@ -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))


Original file line number Diff line number Diff line change
@@ -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


Original file line number Diff line number Diff line change
@@ -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()
Loading