-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yugi
committed
Jan 7, 2025
1 parent
8e6169e
commit ab4f245
Showing
33 changed files
with
730 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
samples/openapi3/client/petstore/python-aiohttp/docs/HuntingDog.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# HuntingDog | ||
|
||
|
||
## Properties | ||
|
||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**is_trained** | **bool** | | [optional] | ||
|
||
## Example | ||
|
||
```python | ||
from petstore_api.models.hunting_dog import HuntingDog | ||
|
||
# TODO update the JSON string below | ||
json = "{}" | ||
# create an instance of HuntingDog from a JSON string | ||
hunting_dog_instance = HuntingDog.from_json(json) | ||
# print the JSON string representation of the object | ||
print(HuntingDog.to_json()) | ||
|
||
# convert the object into a dict | ||
hunting_dog_dict = hunting_dog_instance.to_dict() | ||
# create an instance of HuntingDog from a dict | ||
hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# 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 ConfigDict, Field, StrictBool | ||
from typing import Any, ClassVar, Dict, List, Optional | ||
from petstore_api.models.animal import Animal | ||
from typing import Optional, Set | ||
from typing_extensions import Self | ||
|
||
class HuntingDog(Animal): | ||
""" | ||
HuntingDog | ||
""" # noqa: E501 | ||
is_trained: Optional[StrictBool] = Field(default=None, alias="isTrained") | ||
__properties: ClassVar[List[str]] = ["className", "color", "isTrained"] | ||
|
||
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 HuntingDog 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 HuntingDog from a dict""" | ||
if obj is None: | ||
return None | ||
|
||
if not isinstance(obj, dict): | ||
return cls.model_validate(obj) | ||
|
||
_obj = cls.model_validate({ | ||
"className": obj.get("className"), | ||
"color": obj.get("color") if obj.get("color") is not None else 'red', | ||
"isTrained": obj.get("isTrained") | ||
}) | ||
return _obj | ||
|
||
|
51 changes: 51 additions & 0 deletions
51
samples/openapi3/client/petstore/python-aiohttp/test/test_hunting_dog.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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.hunting_dog import HuntingDog | ||
|
||
class TestHuntingDog(unittest.TestCase): | ||
"""HuntingDog unit test stubs""" | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def make_instance(self, include_optional) -> HuntingDog: | ||
"""Test HuntingDog | ||
include_optional 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 `HuntingDog` | ||
""" | ||
model = HuntingDog() | ||
if include_optional: | ||
return HuntingDog( | ||
is_trained = True | ||
) | ||
else: | ||
return HuntingDog( | ||
) | ||
""" | ||
|
||
def testHuntingDog(self): | ||
"""Test HuntingDog""" | ||
# inst_req_only = self.make_instance(include_optional=False) | ||
# inst_req_and_optional = self.make_instance(include_optional=True) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/HuntingDog.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# HuntingDog | ||
|
||
|
||
## Properties | ||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**is_trained** | **bool** | | [optional] | ||
|
||
## Example | ||
|
||
```python | ||
from petstore_api.models.hunting_dog import HuntingDog | ||
|
||
# TODO update the JSON string below | ||
json = "{}" | ||
# create an instance of HuntingDog from a JSON string | ||
hunting_dog_instance = HuntingDog.from_json(json) | ||
# print the JSON string representation of the object | ||
print HuntingDog.to_json() | ||
|
||
# convert the object into a dict | ||
hunting_dog_dict = hunting_dog_instance.to_dict() | ||
# create an instance of HuntingDog from a dict | ||
hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_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) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.