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:
William Cheng
2025-06-04 16:18:10 +08:00
committed by GitHub
parent 9d70de44d6
commit 4cfc8eff00
43 changed files with 1087 additions and 33 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View 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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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))

View File

@@ -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()

View File

@@ -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()