mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
Add tests for enum names with dots in python cilents (#21374)
* add tests for enum names with dot * remove file * apply same fix to python pydantic v1 * update test
This commit is contained in:
parent
9d70de44d6
commit
4cfc8eff00
@ -1593,6 +1593,8 @@ public abstract class AbstractPythonPydanticV1Codegen extends DefaultCodegen imp
|
||||
}
|
||||
|
||||
public String toEnumVariableName(String name, String datatype) {
|
||||
name = name.replace(".", "_DOT_");
|
||||
|
||||
if ("int".equals(datatype)) {
|
||||
return "NUMBER_" + name.replace("-", "MINUS_");
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: Sample API
|
||||
description: API description in Markdown.
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/pony-sizes:
|
||||
get:
|
||||
summary: Returns all pony sizes.
|
||||
description: Optional extended description in Markdown.
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/PonySizes'
|
||||
components:
|
||||
schemas:
|
||||
PonySizes:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
$ref: '#/components/schemas/Type'
|
||||
Type:
|
||||
type: float
|
||||
enum:
|
||||
- 2.0
|
||||
- 1.0
|
||||
- 0.5
|
||||
- 0.25
|
@ -2898,3 +2898,15 @@ components:
|
||||
- B
|
||||
- C
|
||||
default: B
|
||||
PonySizes:
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
$ref: '#/components/schemas/Type'
|
||||
Type:
|
||||
type: float
|
||||
enum:
|
||||
- 2.0
|
||||
- 1.0
|
||||
- 0.5
|
||||
- 0.25
|
||||
|
@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/PonySizes.md
|
||||
docs/PoopCleaning.md
|
||||
docs/PrimitiveString.md
|
||||
docs/PropertyMap.md
|
||||
@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/Type.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
docs/UnnamedDictWithAdditionalStringListProperties.md
|
||||
docs/UploadFileWithAdditionalPropertiesRequestObject.md
|
||||
@ -215,6 +217,7 @@ petstore_api/models/parent.py
|
||||
petstore_api/models/parent_with_optional_dict.py
|
||||
petstore_api/models/pet.py
|
||||
petstore_api/models/pig.py
|
||||
petstore_api/models/pony_sizes.py
|
||||
petstore_api/models/poop_cleaning.py
|
||||
petstore_api/models/primitive_string.py
|
||||
petstore_api/models/property_map.py
|
||||
@ -238,6 +241,7 @@ 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/type.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
petstore_api/models/unnamed_dict_with_additional_string_list_properties.py
|
||||
petstore_api/models/upload_file_with_additional_properties_request_object.py
|
||||
|
@ -231,6 +231,7 @@ Class | Method | HTTP request | Description
|
||||
- [ParentWithOptionalDict](docs/ParentWithOptionalDict.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [PonySizes](docs/PonySizes.md)
|
||||
- [PoopCleaning](docs/PoopCleaning.md)
|
||||
- [PrimitiveString](docs/PrimitiveString.md)
|
||||
- [PropertyMap](docs/PropertyMap.md)
|
||||
@ -254,6 +255,7 @@ Class | Method | HTTP request | Description
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [Type](docs/Type.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
- [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md)
|
||||
- [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md)
|
||||
|
@ -0,0 +1,29 @@
|
||||
# PonySizes
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**type** | [**Type**](Type.md) | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of PonySizes from a JSON string
|
||||
pony_sizes_instance = PonySizes.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print(PonySizes.to_json())
|
||||
|
||||
# convert the object into a dict
|
||||
pony_sizes_dict = pony_sizes_instance.to_dict()
|
||||
# create an instance of PonySizes from a dict
|
||||
pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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)
|
||||
|
||||
|
16
samples/openapi3/client/petstore/python-aiohttp/docs/Type.md
Normal file
16
samples/openapi3/client/petstore/python-aiohttp/docs/Type.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Type
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `NUMBER_2_DOT_0` (value: `2.0`)
|
||||
|
||||
* `NUMBER_1_DOT_0` (value: `1.0`)
|
||||
|
||||
* `NUMBER_0_DOT_5` (value: `0.5`)
|
||||
|
||||
* `NUMBER_0_DOT_25` (value: `0.25`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -116,6 +116,7 @@ __all__ = [
|
||||
"ParentWithOptionalDict",
|
||||
"Pet",
|
||||
"Pig",
|
||||
"PonySizes",
|
||||
"PoopCleaning",
|
||||
"PrimitiveString",
|
||||
"PropertyMap",
|
||||
@ -139,6 +140,7 @@ __all__ = [
|
||||
"TestModelWithEnumDefault",
|
||||
"TestObjectForMultipartRequestsRequestMarker",
|
||||
"Tiger",
|
||||
"Type",
|
||||
"UnnamedDictWithAdditionalModelListProperties",
|
||||
"UnnamedDictWithAdditionalStringListProperties",
|
||||
"UploadFileWithAdditionalPropertiesRequestObject",
|
||||
@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet as Pet
|
||||
from petstore_api.models.pig import Pig as Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes as PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap as PropertyMap
|
||||
@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger as Tiger
|
||||
from petstore_api.models.type import Type as Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet
|
||||
from petstore_api.models.pig import Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap
|
||||
@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
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.type import Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -0,0 +1,88 @@
|
||||
# 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
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.type import Type
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class PonySizes(BaseModel):
|
||||
"""
|
||||
PonySizes
|
||||
""" # noqa: E501
|
||||
type: Optional[Type] = None
|
||||
__properties: ClassVar[List[str]] = ["type"]
|
||||
|
||||
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 PonySizes 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 PonySizes from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"type": obj.get("type")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
@ -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 Type(int, Enum):
|
||||
"""
|
||||
Type
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
NUMBER_2_DOT_0 = 2.0
|
||||
NUMBER_1_DOT_0 = 1.0
|
||||
NUMBER_0_DOT_5 = 0.5
|
||||
NUMBER_0_DOT_25 = 0.25
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of Type from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -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.pony_sizes import PonySizes
|
||||
|
||||
class TestPonySizes(unittest.TestCase):
|
||||
"""PonySizes unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> PonySizes:
|
||||
"""Test PonySizes
|
||||
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 `PonySizes`
|
||||
"""
|
||||
model = PonySizes()
|
||||
if include_optional:
|
||||
return PonySizes(
|
||||
type = 2.0
|
||||
)
|
||||
else:
|
||||
return PonySizes(
|
||||
)
|
||||
"""
|
||||
|
||||
def testPonySizes(self):
|
||||
"""Test PonySizes"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
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.type import Type
|
||||
|
||||
class TestType(unittest.TestCase):
|
||||
"""Type unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testType(self):
|
||||
"""Test Type"""
|
||||
# inst = Type()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/PonySizes.md
|
||||
docs/PoopCleaning.md
|
||||
docs/PrimitiveString.md
|
||||
docs/PropertyMap.md
|
||||
@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/Type.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
docs/UnnamedDictWithAdditionalStringListProperties.md
|
||||
docs/UploadFileWithAdditionalPropertiesRequestObject.md
|
||||
@ -215,6 +217,7 @@ petstore_api/models/parent.py
|
||||
petstore_api/models/parent_with_optional_dict.py
|
||||
petstore_api/models/pet.py
|
||||
petstore_api/models/pig.py
|
||||
petstore_api/models/pony_sizes.py
|
||||
petstore_api/models/poop_cleaning.py
|
||||
petstore_api/models/primitive_string.py
|
||||
petstore_api/models/property_map.py
|
||||
@ -238,6 +241,7 @@ 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/type.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
petstore_api/models/unnamed_dict_with_additional_string_list_properties.py
|
||||
petstore_api/models/upload_file_with_additional_properties_request_object.py
|
||||
|
@ -232,6 +232,7 @@ Class | Method | HTTP request | Description
|
||||
- [ParentWithOptionalDict](docs/ParentWithOptionalDict.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [PonySizes](docs/PonySizes.md)
|
||||
- [PoopCleaning](docs/PoopCleaning.md)
|
||||
- [PrimitiveString](docs/PrimitiveString.md)
|
||||
- [PropertyMap](docs/PropertyMap.md)
|
||||
@ -255,6 +256,7 @@ Class | Method | HTTP request | Description
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [Type](docs/Type.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
- [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md)
|
||||
- [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md)
|
||||
|
@ -0,0 +1,28 @@
|
||||
# PonySizes
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**type** | [**Type**](Type.md) | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of PonySizes from a JSON string
|
||||
pony_sizes_instance = PonySizes.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print PonySizes.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
pony_sizes_dict = pony_sizes_instance.to_dict()
|
||||
# create an instance of PonySizes from a dict
|
||||
pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# Type
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `NUMBER_2_DOT_0` (value: `2.0`)
|
||||
|
||||
* `NUMBER_1_DOT_0` (value: `1.0`)
|
||||
|
||||
* `NUMBER_0_DOT_5` (value: `0.5`)
|
||||
|
||||
* `NUMBER_0_DOT_25` (value: `0.25`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -116,6 +116,7 @@ __all__ = [
|
||||
"ParentWithOptionalDict",
|
||||
"Pet",
|
||||
"Pig",
|
||||
"PonySizes",
|
||||
"PoopCleaning",
|
||||
"PrimitiveString",
|
||||
"PropertyMap",
|
||||
@ -139,6 +140,7 @@ __all__ = [
|
||||
"TestModelWithEnumDefault",
|
||||
"TestObjectForMultipartRequestsRequestMarker",
|
||||
"Tiger",
|
||||
"Type",
|
||||
"UnnamedDictWithAdditionalModelListProperties",
|
||||
"UnnamedDictWithAdditionalStringListProperties",
|
||||
"UploadFileWithAdditionalPropertiesRequestObject",
|
||||
@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet as Pet
|
||||
from petstore_api.models.pig import Pig as Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes as PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap as PropertyMap
|
||||
@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger as Tiger
|
||||
from petstore_api.models.type import Type as Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet
|
||||
from petstore_api.models.pig import Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap
|
||||
@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
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.type import Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -0,0 +1,72 @@
|
||||
# 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
|
||||
from petstore_api.models.type import Type
|
||||
|
||||
class PonySizes(BaseModel):
|
||||
"""
|
||||
PonySizes
|
||||
"""
|
||||
type: Optional[Type] = None
|
||||
__properties = ["type"]
|
||||
|
||||
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) -> PonySizes:
|
||||
"""Create an instance of PonySizes 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) -> PonySizes:
|
||||
"""Create an instance of PonySizes from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return PonySizes.parse_obj(obj)
|
||||
|
||||
_obj = PonySizes.parse_obj({
|
||||
"type": obj.get("type")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
@ -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 Type(int, Enum):
|
||||
"""
|
||||
Type
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
NUMBER_2_DOT_0 = 2.0
|
||||
NUMBER_1_DOT_0 = 1.0
|
||||
NUMBER_0_DOT_5 = 0.5
|
||||
NUMBER_0_DOT_25 = 0.25
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Type:
|
||||
"""Create an instance of Type from a JSON string"""
|
||||
return Type(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
# 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.pony_sizes import PonySizes # noqa: E501
|
||||
|
||||
class TestPonySizes(unittest.TestCase):
|
||||
"""PonySizes unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> PonySizes:
|
||||
"""Test PonySizes
|
||||
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 `PonySizes`
|
||||
"""
|
||||
model = PonySizes() # noqa: E501
|
||||
if include_optional:
|
||||
return PonySizes(
|
||||
type = 2.0
|
||||
)
|
||||
else:
|
||||
return PonySizes(
|
||||
)
|
||||
"""
|
||||
|
||||
def testPonySizes(self):
|
||||
"""Test PonySizes"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
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.type import Type # noqa: E501
|
||||
|
||||
class TestType(unittest.TestCase):
|
||||
"""Type unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testType(self):
|
||||
"""Test Type"""
|
||||
# inst = Type()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/PonySizes.md
|
||||
docs/PoopCleaning.md
|
||||
docs/PrimitiveString.md
|
||||
docs/PropertyMap.md
|
||||
@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/Type.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
docs/UnnamedDictWithAdditionalStringListProperties.md
|
||||
docs/UploadFileWithAdditionalPropertiesRequestObject.md
|
||||
@ -215,6 +217,7 @@ petstore_api/models/parent.py
|
||||
petstore_api/models/parent_with_optional_dict.py
|
||||
petstore_api/models/pet.py
|
||||
petstore_api/models/pig.py
|
||||
petstore_api/models/pony_sizes.py
|
||||
petstore_api/models/poop_cleaning.py
|
||||
petstore_api/models/primitive_string.py
|
||||
petstore_api/models/property_map.py
|
||||
@ -238,6 +241,7 @@ 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/type.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
petstore_api/models/unnamed_dict_with_additional_string_list_properties.py
|
||||
petstore_api/models/upload_file_with_additional_properties_request_object.py
|
||||
|
@ -232,6 +232,7 @@ Class | Method | HTTP request | Description
|
||||
- [ParentWithOptionalDict](docs/ParentWithOptionalDict.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [PonySizes](docs/PonySizes.md)
|
||||
- [PoopCleaning](docs/PoopCleaning.md)
|
||||
- [PrimitiveString](docs/PrimitiveString.md)
|
||||
- [PropertyMap](docs/PropertyMap.md)
|
||||
@ -255,6 +256,7 @@ Class | Method | HTTP request | Description
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [Type](docs/Type.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
- [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md)
|
||||
- [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md)
|
||||
|
@ -0,0 +1,28 @@
|
||||
# PonySizes
|
||||
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**type** | [**Type**](Type.md) | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of PonySizes from a JSON string
|
||||
pony_sizes_instance = PonySizes.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print PonySizes.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
pony_sizes_dict = pony_sizes_instance.to_dict()
|
||||
# create an instance of PonySizes from a dict
|
||||
pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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)
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
# Type
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `NUMBER_2_DOT_0` (value: `2.0`)
|
||||
|
||||
* `NUMBER_1_DOT_0` (value: `1.0`)
|
||||
|
||||
* `NUMBER_0_DOT_5` (value: `0.5`)
|
||||
|
||||
* `NUMBER_0_DOT_25` (value: `0.25`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -116,6 +116,7 @@ __all__ = [
|
||||
"ParentWithOptionalDict",
|
||||
"Pet",
|
||||
"Pig",
|
||||
"PonySizes",
|
||||
"PoopCleaning",
|
||||
"PrimitiveString",
|
||||
"PropertyMap",
|
||||
@ -139,6 +140,7 @@ __all__ = [
|
||||
"TestModelWithEnumDefault",
|
||||
"TestObjectForMultipartRequestsRequestMarker",
|
||||
"Tiger",
|
||||
"Type",
|
||||
"UnnamedDictWithAdditionalModelListProperties",
|
||||
"UnnamedDictWithAdditionalStringListProperties",
|
||||
"UploadFileWithAdditionalPropertiesRequestObject",
|
||||
@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet as Pet
|
||||
from petstore_api.models.pig import Pig as Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes as PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap as PropertyMap
|
||||
@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger as Tiger
|
||||
from petstore_api.models.type import Type as Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet
|
||||
from petstore_api.models.pig import Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap
|
||||
@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
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.type import Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -0,0 +1,84 @@
|
||||
# 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
|
||||
from petstore_api.models.type import Type
|
||||
|
||||
class PonySizes(BaseModel):
|
||||
"""
|
||||
PonySizes
|
||||
"""
|
||||
type: Optional[Type] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties = ["type"]
|
||||
|
||||
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) -> PonySizes:
|
||||
"""Create an instance of PonySizes 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) -> PonySizes:
|
||||
"""Create an instance of PonySizes from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return PonySizes.parse_obj(obj)
|
||||
|
||||
_obj = PonySizes.parse_obj({
|
||||
"type": obj.get("type")
|
||||
})
|
||||
# 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,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 Type(int, Enum):
|
||||
"""
|
||||
Type
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
NUMBER_2_DOT_0 = 2.0
|
||||
NUMBER_1_DOT_0 = 1.0
|
||||
NUMBER_0_DOT_5 = 0.5
|
||||
NUMBER_0_DOT_25 = 0.25
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Type:
|
||||
"""Create an instance of Type from a JSON string"""
|
||||
return Type(json.loads(json_str))
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
# 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.pony_sizes import PonySizes # noqa: E501
|
||||
|
||||
class TestPonySizes(unittest.TestCase):
|
||||
"""PonySizes unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> PonySizes:
|
||||
"""Test PonySizes
|
||||
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 `PonySizes`
|
||||
"""
|
||||
model = PonySizes() # noqa: E501
|
||||
if include_optional:
|
||||
return PonySizes(
|
||||
type = 2.0
|
||||
)
|
||||
else:
|
||||
return PonySizes(
|
||||
)
|
||||
"""
|
||||
|
||||
def testPonySizes(self):
|
||||
"""Test PonySizes"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
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.type import Type # noqa: E501
|
||||
|
||||
class TestType(unittest.TestCase):
|
||||
"""Type unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testType(self):
|
||||
"""Test Type"""
|
||||
# inst = Type()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -89,6 +89,7 @@ docs/ParentWithOptionalDict.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/PonySizes.md
|
||||
docs/PoopCleaning.md
|
||||
docs/PrimitiveString.md
|
||||
docs/PropertyMap.md
|
||||
@ -113,6 +114,7 @@ docs/TestInlineFreeformAdditionalPropertiesRequest.md
|
||||
docs/TestModelWithEnumDefault.md
|
||||
docs/TestObjectForMultipartRequestsRequestMarker.md
|
||||
docs/Tiger.md
|
||||
docs/Type.md
|
||||
docs/UnnamedDictWithAdditionalModelListProperties.md
|
||||
docs/UnnamedDictWithAdditionalStringListProperties.md
|
||||
docs/UploadFileWithAdditionalPropertiesRequestObject.md
|
||||
@ -215,6 +217,7 @@ petstore_api/models/parent.py
|
||||
petstore_api/models/parent_with_optional_dict.py
|
||||
petstore_api/models/pet.py
|
||||
petstore_api/models/pig.py
|
||||
petstore_api/models/pony_sizes.py
|
||||
petstore_api/models/poop_cleaning.py
|
||||
petstore_api/models/primitive_string.py
|
||||
petstore_api/models/property_map.py
|
||||
@ -238,6 +241,7 @@ 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/type.py
|
||||
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py
|
||||
petstore_api/models/unnamed_dict_with_additional_string_list_properties.py
|
||||
petstore_api/models/upload_file_with_additional_properties_request_object.py
|
||||
|
@ -231,6 +231,7 @@ Class | Method | HTTP request | Description
|
||||
- [ParentWithOptionalDict](docs/ParentWithOptionalDict.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [PonySizes](docs/PonySizes.md)
|
||||
- [PoopCleaning](docs/PoopCleaning.md)
|
||||
- [PrimitiveString](docs/PrimitiveString.md)
|
||||
- [PropertyMap](docs/PropertyMap.md)
|
||||
@ -254,6 +255,7 @@ Class | Method | HTTP request | Description
|
||||
- [TestModelWithEnumDefault](docs/TestModelWithEnumDefault.md)
|
||||
- [TestObjectForMultipartRequestsRequestMarker](docs/TestObjectForMultipartRequestsRequestMarker.md)
|
||||
- [Tiger](docs/Tiger.md)
|
||||
- [Type](docs/Type.md)
|
||||
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)
|
||||
- [UnnamedDictWithAdditionalStringListProperties](docs/UnnamedDictWithAdditionalStringListProperties.md)
|
||||
- [UploadFileWithAdditionalPropertiesRequestObject](docs/UploadFileWithAdditionalPropertiesRequestObject.md)
|
||||
|
29
samples/openapi3/client/petstore/python/docs/PonySizes.md
Normal file
29
samples/openapi3/client/petstore/python/docs/PonySizes.md
Normal file
@ -0,0 +1,29 @@
|
||||
# PonySizes
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**type** | [**Type**](Type.md) | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of PonySizes from a JSON string
|
||||
pony_sizes_instance = PonySizes.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print(PonySizes.to_json())
|
||||
|
||||
# convert the object into a dict
|
||||
pony_sizes_dict = pony_sizes_instance.to_dict()
|
||||
# create an instance of PonySizes from a dict
|
||||
pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_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)
|
||||
|
||||
|
16
samples/openapi3/client/petstore/python/docs/Type.md
Normal file
16
samples/openapi3/client/petstore/python/docs/Type.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Type
|
||||
|
||||
|
||||
## Enum
|
||||
|
||||
* `NUMBER_2_DOT_0` (value: `2.0`)
|
||||
|
||||
* `NUMBER_1_DOT_0` (value: `1.0`)
|
||||
|
||||
* `NUMBER_0_DOT_5` (value: `0.5`)
|
||||
|
||||
* `NUMBER_0_DOT_25` (value: `0.25`)
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -116,6 +116,7 @@ __all__ = [
|
||||
"ParentWithOptionalDict",
|
||||
"Pet",
|
||||
"Pig",
|
||||
"PonySizes",
|
||||
"PoopCleaning",
|
||||
"PrimitiveString",
|
||||
"PropertyMap",
|
||||
@ -139,6 +140,7 @@ __all__ = [
|
||||
"TestModelWithEnumDefault",
|
||||
"TestObjectForMultipartRequestsRequestMarker",
|
||||
"Tiger",
|
||||
"Type",
|
||||
"UnnamedDictWithAdditionalModelListProperties",
|
||||
"UnnamedDictWithAdditionalStringListProperties",
|
||||
"UploadFileWithAdditionalPropertiesRequestObject",
|
||||
@ -249,6 +251,7 @@ from petstore_api.models.parent import Parent as Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict as ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet as Pet
|
||||
from petstore_api.models.pig import Pig as Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes as PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning as PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString as PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap as PropertyMap
|
||||
@ -272,6 +275,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDefault as TestModelWithEnumDefault
|
||||
from petstore_api.models.test_object_for_multipart_requests_request_marker import TestObjectForMultipartRequestsRequestMarker as TestObjectForMultipartRequestsRequestMarker
|
||||
from petstore_api.models.tiger import Tiger as Tiger
|
||||
from petstore_api.models.type import Type as Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties as UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties as UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject as UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -94,6 +94,7 @@ from petstore_api.models.parent import Parent
|
||||
from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
||||
from petstore_api.models.pet import Pet
|
||||
from petstore_api.models.pig import Pig
|
||||
from petstore_api.models.pony_sizes import PonySizes
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||
from petstore_api.models.primitive_string import PrimitiveString
|
||||
from petstore_api.models.property_map import PropertyMap
|
||||
@ -117,6 +118,7 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo
|
||||
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.type import Type
|
||||
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties
|
||||
from petstore_api.models.unnamed_dict_with_additional_string_list_properties import UnnamedDictWithAdditionalStringListProperties
|
||||
from petstore_api.models.upload_file_with_additional_properties_request_object import UploadFileWithAdditionalPropertiesRequestObject
|
||||
|
@ -0,0 +1,101 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.type import Type
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class PonySizes(BaseModel):
|
||||
"""
|
||||
PonySizes
|
||||
""" # noqa: E501
|
||||
type: Optional[Type] = None
|
||||
additional_properties: Dict[str, Any] = {}
|
||||
__properties: ClassVar[List[str]] = ["type"]
|
||||
|
||||
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 PonySizes 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 PonySizes from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"type": obj.get("type")
|
||||
})
|
||||
# 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,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 Type(int, Enum):
|
||||
"""
|
||||
Type
|
||||
"""
|
||||
|
||||
"""
|
||||
allowed enum values
|
||||
"""
|
||||
NUMBER_2_DOT_0 = 2.0
|
||||
NUMBER_1_DOT_0 = 1.0
|
||||
NUMBER_0_DOT_5 = 0.5
|
||||
NUMBER_0_DOT_25 = 0.25
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of Type from a JSON string"""
|
||||
return cls(json.loads(json_str))
|
||||
|
||||
|
@ -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.pony_sizes import PonySizes
|
||||
|
||||
class TestPonySizes(unittest.TestCase):
|
||||
"""PonySizes unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> PonySizes:
|
||||
"""Test PonySizes
|
||||
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 `PonySizes`
|
||||
"""
|
||||
model = PonySizes()
|
||||
if include_optional:
|
||||
return PonySizes(
|
||||
type = 2.0
|
||||
)
|
||||
else:
|
||||
return PonySizes(
|
||||
)
|
||||
"""
|
||||
|
||||
def testPonySizes(self):
|
||||
"""Test PonySizes"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
33
samples/openapi3/client/petstore/python/test/test_type.py
Normal file
33
samples/openapi3/client/petstore/python/test/test_type.py
Normal file
@ -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.type import Type
|
||||
|
||||
class TestType(unittest.TestCase):
|
||||
"""Type unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def testType(self):
|
||||
"""Test Type"""
|
||||
# inst = Type()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user