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 @@ -2975,3 +2975,29 @@ components:
type: string
recursive:
type: boolean
# schemas to test `not`
Known:
type: object
required:
- kind
properties:
kind:
type: string
enum:
- known
Other:
type: object
required:
- kind
properties:
kind:
type: string
not:
enum:
- known
- reserved
TaggedUnion:
oneOf:
- $ref: '#/components/schemas/Known'
- $ref: '#/components/schemas/Other'
# -- end of schemas to test `not`
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ docs/Info.md
docs/InnerDictWithProperty.md
docs/InputAllOf.md
docs/IntOrString.md
docs/Known.md
docs/ListClass.md
docs/MapOfArrayOfModel.md
docs/MapTest.md
Expand All @@ -82,6 +83,7 @@ docs/ObjectToTestAdditionalProperties.md
docs/ObjectWithDeprecatedFields.md
docs/OneOfEnumString.md
docs/Order.md
docs/Other.md
docs/OuterComposite.md
docs/OuterEnum.md
docs/OuterEnumDefaultValue.md
Expand All @@ -108,6 +110,7 @@ docs/SpecialModelName.md
docs/SpecialName.md
docs/StoreApi.md
docs/Tag.md
docs/TaggedUnion.md
docs/Task.md
docs/TaskActivity.md
docs/TestEnum.md
Expand Down Expand Up @@ -199,6 +202,7 @@ petstore_api/models/info.py
petstore_api/models/inner_dict_with_property.py
petstore_api/models/input_all_of.py
petstore_api/models/int_or_string.py
petstore_api/models/known.py
petstore_api/models/list_class.py
petstore_api/models/map_of_array_of_model.py
petstore_api/models/map_test.py
Expand All @@ -216,6 +220,7 @@ petstore_api/models/object_to_test_additional_properties.py
petstore_api/models/object_with_deprecated_fields.py
petstore_api/models/one_of_enum_string.py
petstore_api/models/order.py
petstore_api/models/other.py
petstore_api/models/outer_composite.py
petstore_api/models/outer_enum.py
petstore_api/models/outer_enum_default_value.py
Expand All @@ -240,6 +245,7 @@ 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/tagged_union.py
petstore_api/models/task.py
petstore_api/models/task_activity.py
petstore_api/models/test_enum.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 @@ -236,6 +236,7 @@ Class | Method | HTTP request | Description
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
- [InputAllOf](docs/InputAllOf.md)
- [IntOrString](docs/IntOrString.md)
- [Known](docs/Known.md)
- [ListClass](docs/ListClass.md)
- [MapOfArrayOfModel](docs/MapOfArrayOfModel.md)
- [MapTest](docs/MapTest.md)
Expand All @@ -253,6 +254,7 @@ Class | Method | HTTP request | Description
- [ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
- [OneOfEnumString](docs/OneOfEnumString.md)
- [Order](docs/Order.md)
- [Other](docs/Other.md)
- [OuterComposite](docs/OuterComposite.md)
- [OuterEnum](docs/OuterEnum.md)
- [OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
Expand All @@ -277,6 +279,7 @@ Class | Method | HTTP request | Description
- [SpecialModelName](docs/SpecialModelName.md)
- [SpecialName](docs/SpecialName.md)
- [Tag](docs/Tag.md)
- [TaggedUnion](docs/TaggedUnion.md)
- [Task](docs/Task.md)
- [TaskActivity](docs/TaskActivity.md)
- [TestEnum](docs/TestEnum.md)
Expand Down
29 changes: 29 additions & 0 deletions samples/openapi3/client/petstore/python-aiohttp/docs/Known.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Known


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | **str** | |

## Example

```python
from petstore_api.models.known import Known

# TODO update the JSON string below
json = "{}"
# create an instance of Known from a JSON string
known_instance = Known.from_json(json)
# print the JSON string representation of the object
print(Known.to_json())

# convert the object into a dict
known_dict = known_instance.to_dict()
# create an instance of Known from a dict
known_from_dict = Known.from_dict(known_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)


29 changes: 29 additions & 0 deletions samples/openapi3/client/petstore/python-aiohttp/docs/Other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Other


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | **str** | |

## Example

```python
from petstore_api.models.other import Other

# TODO update the JSON string below
json = "{}"
# create an instance of Other from a JSON string
other_instance = Other.from_json(json)
# print the JSON string representation of the object
print(Other.to_json())

# convert the object into a dict
other_dict = other_instance.to_dict()
# create an instance of Other from a dict
other_from_dict = Other.from_dict(other_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
@@ -0,0 +1,29 @@
# TaggedUnion


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | **str** | |

## Example

```python
from petstore_api.models.tagged_union import TaggedUnion

# TODO update the JSON string below
json = "{}"
# create an instance of TaggedUnion from a JSON string
tagged_union_instance = TaggedUnion.from_json(json)
# print the JSON string representation of the object
print(TaggedUnion.to_json())

# convert the object into a dict
tagged_union_dict = tagged_union_instance.to_dict()
# create an instance of TaggedUnion from a dict
tagged_union_from_dict = TaggedUnion.from_dict(tagged_union_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 @@ -93,6 +93,7 @@
"InnerDictWithProperty",
"InputAllOf",
"IntOrString",
"Known",
"ListClass",
"MapOfArrayOfModel",
"MapTest",
Expand All @@ -110,6 +111,7 @@
"ObjectWithDeprecatedFields",
"OneOfEnumString",
"Order",
"Other",
"OuterComposite",
"OuterEnum",
"OuterEnumDefaultValue",
Expand All @@ -134,6 +136,7 @@
"SpecialModelName",
"SpecialName",
"Tag",
"TaggedUnion",
"Task",
"TaskActivity",
"TestEnum",
Expand Down Expand Up @@ -233,6 +236,7 @@
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty as InnerDictWithProperty
from petstore_api.models.input_all_of import InputAllOf as InputAllOf
from petstore_api.models.int_or_string import IntOrString as IntOrString
from petstore_api.models.known import Known as Known
from petstore_api.models.list_class import ListClass as ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel as MapOfArrayOfModel
from petstore_api.models.map_test import MapTest as MapTest
Expand All @@ -250,6 +254,7 @@
from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields as ObjectWithDeprecatedFields
from petstore_api.models.one_of_enum_string import OneOfEnumString as OneOfEnumString
from petstore_api.models.order import Order as Order
from petstore_api.models.other import Other as Other
from petstore_api.models.outer_composite import OuterComposite as OuterComposite
from petstore_api.models.outer_enum import OuterEnum as OuterEnum
from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue as OuterEnumDefaultValue
Expand All @@ -274,6 +279,7 @@
from petstore_api.models.special_model_name import SpecialModelName as SpecialModelName
from petstore_api.models.special_name import SpecialName as SpecialName
from petstore_api.models.tag import Tag as Tag
from petstore_api.models.tagged_union import TaggedUnion as TaggedUnion
from petstore_api.models.task import Task as Task
from petstore_api.models.task_activity import TaskActivity as TaskActivity
from petstore_api.models.test_enum import TestEnum as TestEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.input_all_of import InputAllOf
from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.known import Known
from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest
Expand All @@ -87,6 +88,7 @@
from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecatedFields
from petstore_api.models.one_of_enum_string import OneOfEnumString
from petstore_api.models.order import Order
from petstore_api.models.other import Other
from petstore_api.models.outer_composite import OuterComposite
from petstore_api.models.outer_enum import OuterEnum
from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue
Expand All @@ -111,6 +113,7 @@
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.tagged_union import TaggedUnion
from petstore_api.models.task import Task
from petstore_api.models.task_activity import TaskActivity
from petstore_api.models.test_enum import TestEnum
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# 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
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class Known(BaseModel):
"""
Known
""" # noqa: E501
kind: StrictStr
__properties: ClassVar[List[str]] = ["kind"]

@field_validator('kind')
def kind_validate_enum(cls, value):
"""Validates the enum"""
if value not in set(['known']):
raise ValueError("must be one of enum values ('known')")
return value

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=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"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of Known 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 Known from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"kind": obj.get("kind")
})
return _obj


Loading
Loading