[python] change Private attr to Class vars (#16687)

* [python] fix TypeError

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update Private model attributes to Class vars

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] update samples

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of v1 test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* [python] rename the List of v1-aiohttp test cases to ListClass

Signed-off-by: ふぁ <yuki@yuki0311.com>

* update samples

---------

Signed-off-by: ふぁ <yuki@yuki0311.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
ふぁ 2023-10-01 17:52:23 +09:00 committed by GitHub
parent e2f249ba35
commit c6e9a4e1ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
171 changed files with 962 additions and 334 deletions

View File

@ -948,7 +948,9 @@ public abstract class AbstractPythonCodegen extends DefaultCodegen implements Co
&& !model.isEnum && !model.isEnum
&& !this.disallowAdditionalPropertiesIfNotPresent) { && !this.disallowAdditionalPropertiesIfNotPresent) {
typingImports.add("Dict"); typingImports.add("Dict");
typingImports.add("List");
typingImports.add("Any"); typingImports.add("Any");
typingImports.add("ClassVar");
} }
//loop through properties/schemas to set up typing, pydantic //loop through properties/schemas to set up typing, pydantic

View File

@ -23,7 +23,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesTrue}}
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}
__properties = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}] __properties: ClassVar[List[str]] = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}]
{{#vars}} {{#vars}}
{{#vendorExtensions.x-regex}} {{#vendorExtensions.x-regex}}
@ -85,27 +85,21 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#hasChildren}} {{#hasChildren}}
{{#discriminator}} {{#discriminator}}
# JSON field name that stores the object type # JSON field name that stores the object type
__discriminator_property_name = '{{discriminator.propertyBaseName}}' __discriminator_property_name: ClassVar[List[str]] = '{{discriminator.propertyBaseName}}'
{{#mappedModels}}
{{#-first}}
# discriminator mappings # discriminator mappings
__discriminator_value_class_map = { __discriminator_value_class_map: ClassVar[Dict[str, str]] = {
{{/-first}} {{#mappedModels}}'{{{mappingName}}}': '{{{modelName}}}'{{^-last}},{{/-last}}{{/mappedModels}}
'{{{mappingName}}}': '{{{modelName}}}'{{^-last}},{{/-last}}
{{#-last}}
} }
@classmethod @classmethod
def get_discriminator_value(cls, obj: dict) -> str: def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data""" """Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name.default] discriminator_value = obj[cls.__discriminator_property_name]
if discriminator_value: if discriminator_value:
return cls.__discriminator_value_class_map.default.get(discriminator_value) return cls.__discriminator_value_class_map.get(discriminator_value)
else: else:
return None return None
{{/-last}}
{{/mappedModels}}
{{/discriminator}} {{/discriminator}}
{{/hasChildren}} {{/hasChildren}}
@ -232,8 +226,8 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return klass.from_dict(obj) return klass.from_dict(obj)
else: else:
raise ValueError("{{{classname}}} failed to lookup discriminator value from " + raise ValueError("{{{classname}}} failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name.default + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
", mapping: " + json.dumps(cls.__discriminator_value_class_map.default)) ", mapping: " + json.dumps(cls.__discriminator_value_class_map))
{{/discriminator}} {{/discriminator}}
{{/hasChildren}} {{/hasChildren}}
{{^hasChildren}} {{^hasChildren}}
@ -248,7 +242,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
# raise errors for additional fields in the input # raise errors for additional fields in the input
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties:
raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj) raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + _key)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}
{{/disallowAdditionalPropertiesIfNotPresent}} {{/disallowAdditionalPropertiesIfNotPresent}}
@ -351,7 +345,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesTrue}}
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesTrue}}

View File

@ -1776,7 +1776,7 @@ components:
type: object type: object
additionalProperties: additionalProperties:
$ref: '#/components/schemas/Animal' $ref: '#/components/schemas/Animal'
List: ListClass:
type: object type: object
properties: properties:
123-list: 123-list:

View File

@ -28,7 +28,7 @@ class Bird(BaseModel):
""" """
size: Optional[StrictStr] = None size: Optional[StrictStr] = None
color: Optional[StrictStr] = None color: Optional[StrictStr] = None
__properties = ["size", "color"] __properties: ClassVar[List[str]] = ["size", "color"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class Category(BaseModel):
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
__properties = ["id", "name"] __properties: ClassVar[List[str]] = ["id", "name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -31,7 +31,7 @@ class DataQuery(Query):
suffix: Optional[StrictStr] = Field(default=None, description="test suffix") suffix: Optional[StrictStr] = Field(default=None, description="test suffix")
text: Optional[StrictStr] = Field(default=None, description="Some text containing white spaces") text: Optional[StrictStr] = Field(default=None, description="Some text containing white spaces")
var_date: Optional[datetime] = Field(default=None, description="A date", alias="date") var_date: Optional[datetime] = Field(default=None, description="A date", alias="date")
__properties = ["id", "outcomes", "suffix", "text", "date"] __properties: ClassVar[List[str]] = ["id", "outcomes", "suffix", "text", "date"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -35,7 +35,7 @@ class DefaultValue(BaseModel):
array_string_nullable: Optional[List[StrictStr]] = None array_string_nullable: Optional[List[StrictStr]] = None
array_string_extension_nullable: Optional[List[StrictStr]] = None array_string_extension_nullable: Optional[List[StrictStr]] = None
string_nullable: Optional[StrictStr] = None string_nullable: Optional[StrictStr] = None
__properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"] __properties: ClassVar[List[str]] = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "array_string_extension_nullable", "string_nullable"]
@field_validator('array_string_enum_default') @field_validator('array_string_enum_default')
def array_string_enum_default_validate_enum(cls, value): def array_string_enum_default_validate_enum(cls, value):

View File

@ -30,7 +30,7 @@ class NumberPropertiesOnly(BaseModel):
""" """
number: Optional[Union[StrictFloat, StrictInt]] = None number: Optional[Union[StrictFloat, StrictInt]] = None
double: Optional[Union[Annotated[float, Field(le=50.2, strict=True, ge=0.8)], Annotated[int, Field(le=50, strict=True, ge=1)]]] = None double: Optional[Union[Annotated[float, Field(le=50.2, strict=True, ge=0.8)], Annotated[int, Field(le=50, strict=True, ge=1)]]] = None
__properties = ["number", "double"] __properties: ClassVar[List[str]] = ["number", "double"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -35,7 +35,7 @@ class Pet(BaseModel):
photo_urls: List[StrictStr] = Field(alias="photoUrls") photo_urls: List[StrictStr] = Field(alias="photoUrls")
tags: Optional[List[Tag]] = None tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(default=None, description="pet status in the store") status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
__properties = ["id", "name", "category", "photoUrls", "tags", "status"] __properties: ClassVar[List[str]] = ["id", "name", "category", "photoUrls", "tags", "status"]
@field_validator('status') @field_validator('status')
def status_validate_enum(cls, value): def status_validate_enum(cls, value):

View File

@ -29,7 +29,7 @@ class Query(BaseModel):
""" """
id: Optional[StrictInt] = Field(default=None, description="Query") id: Optional[StrictInt] = Field(default=None, description="Query")
outcomes: Optional[List[StrictStr]] = None outcomes: Optional[List[StrictStr]] = None
__properties = ["id", "outcomes"] __properties: ClassVar[List[str]] = ["id", "outcomes"]
@field_validator('outcomes') @field_validator('outcomes')
def outcomes_validate_enum(cls, value): def outcomes_validate_enum(cls, value):

View File

@ -28,7 +28,7 @@ class Tag(BaseModel):
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
__properties = ["id", "name"] __properties: ClassVar[List[str]] = ["id", "name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -30,7 +30,7 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod
color: Optional[StrictStr] = None color: Optional[StrictStr] = None
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
__properties = ["size", "color", "id", "name"] __properties: ClassVar[List[str]] = ["size", "color", "id", "name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
""" """
values: Optional[List[StrictStr]] = None values: Optional[List[StrictStr]] = None
__properties = ["values"] __properties: ClassVar[List[str]] = ["values"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -49,7 +49,7 @@ docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md docs/HealthCheckResult.md
docs/InnerDictWithProperty.md docs/InnerDictWithProperty.md
docs/IntOrString.md docs/IntOrString.md
docs/List.md docs/ListClass.md
docs/MapOfArrayOfModel.md docs/MapOfArrayOfModel.md
docs/MapTest.md docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/MixedPropertiesAndAdditionalPropertiesClass.md
@ -146,7 +146,7 @@ petstore_api/models/has_only_read_only.py
petstore_api/models/health_check_result.py petstore_api/models/health_check_result.py
petstore_api/models/inner_dict_with_property.py petstore_api/models/inner_dict_with_property.py
petstore_api/models/int_or_string.py petstore_api/models/int_or_string.py
petstore_api/models/list.py petstore_api/models/list_class.py
petstore_api/models/map_of_array_of_model.py petstore_api/models/map_of_array_of_model.py
petstore_api/models/map_test.py petstore_api/models/map_test.py
petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/mixed_properties_and_additional_properties_class.py

View File

@ -177,7 +177,7 @@ Class | Method | HTTP request | Description
- [HealthCheckResult](docs/HealthCheckResult.md) - [HealthCheckResult](docs/HealthCheckResult.md)
- [InnerDictWithProperty](docs/InnerDictWithProperty.md) - [InnerDictWithProperty](docs/InnerDictWithProperty.md)
- [IntOrString](docs/IntOrString.md) - [IntOrString](docs/IntOrString.md)
- [List](docs/List.md) - [ListClass](docs/ListClass.md)
- [MapOfArrayOfModel](docs/MapOfArrayOfModel.md) - [MapOfArrayOfModel](docs/MapOfArrayOfModel.md)
- [MapTest](docs/MapTest.md) - [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)

View File

@ -0,0 +1,28 @@
# ListClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**var_123_list** | **str** | | [optional]
## Example
```python
from petstore_api.models.list_class import ListClass
# TODO update the JSON string below
json = "{}"
# create an instance of ListClass from a JSON string
list_class_instance = ListClass.from_json(json)
# print the JSON string representation of the object
print ListClass.to_json()
# convert the object into a dict
list_class_dict = list_class_instance.to_dict()
# create an instance of ListClass from a dict
list_class_form_dict = list_class.from_dict(list_class_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

@ -80,7 +80,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -56,7 +56,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -27,7 +27,7 @@ class AdditionalPropertiesAnyType(BaseModel):
""" """
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
__properties = ["name"] __properties: ClassVar[List[str]] = ["name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -77,7 +77,7 @@ class AdditionalPropertiesAnyType(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -27,7 +27,7 @@ class AdditionalPropertiesClass(BaseModel):
""" """
map_property: Optional[Dict[str, StrictStr]] = None map_property: Optional[Dict[str, StrictStr]] = None
map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None map_of_map_property: Optional[Dict[str, Dict[str, StrictStr]]] = None
__properties = ["map_property", "map_of_map_property"] __properties: ClassVar[List[str]] = ["map_property", "map_of_map_property"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class AdditionalPropertiesObject(BaseModel):
""" """
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
__properties = ["name"] __properties: ClassVar[List[str]] = ["name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -77,7 +77,7 @@ class AdditionalPropertiesObject(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -27,7 +27,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
""" """
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
__properties = ["name"] __properties: ClassVar[List[str]] = ["name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -77,7 +77,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -29,7 +29,7 @@ class AllOfWithSingleRef(BaseModel):
""" """
username: Optional[StrictStr] = None username: Optional[StrictStr] = None
single_ref_type: Optional[SingleRefType] = Field(default=None, alias="SingleRefType") single_ref_type: Optional[SingleRefType] = Field(default=None, alias="SingleRefType")
__properties = ["username", "SingleRefType"] __properties: ClassVar[List[str]] = ["username", "SingleRefType"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class Animal(BaseModel):
""" """
class_name: StrictStr = Field(alias="className") class_name: StrictStr = Field(alias="className")
color: Optional[StrictStr] = 'red' color: Optional[StrictStr] = 'red'
__properties = ["className", "color"] __properties: ClassVar[List[str]] = ["className", "color"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -37,20 +37,19 @@ class Animal(BaseModel):
# JSON field name that stores the object type # JSON field name that stores the object type
__discriminator_property_name = 'className' __discriminator_property_name: ClassVar[List[str]] = 'className'
# discriminator mappings # discriminator mappings
__discriminator_value_class_map = { __discriminator_value_class_map: ClassVar[Dict[str, str]] = {
'Cat': 'Cat', 'Cat': 'Cat','Dog': 'Dog'
'Dog': 'Dog'
} }
@classmethod @classmethod
def get_discriminator_value(cls, obj: dict) -> str: def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data""" """Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name.default] discriminator_value = obj[cls.__discriminator_property_name]
if discriminator_value: if discriminator_value:
return cls.__discriminator_value_class_map.default.get(discriminator_value) return cls.__discriminator_value_class_map.get(discriminator_value)
else: else:
return None return None
@ -86,8 +85,8 @@ class Animal(BaseModel):
return klass.from_dict(obj) return klass.from_dict(obj)
else: else:
raise ValueError("Animal failed to lookup discriminator value from " + raise ValueError("Animal failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name.default + json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
", mapping: " + json.dumps(cls.__discriminator_value_class_map.default)) ", mapping: " + json.dumps(cls.__discriminator_value_class_map))
from petstore_api.models.cat import Cat from petstore_api.models.cat import Cat
from petstore_api.models.dog import Dog from petstore_api.models.dog import Dog

View File

@ -28,7 +28,7 @@ class ApiResponse(BaseModel):
code: Optional[StrictInt] = None code: Optional[StrictInt] = None
type: Optional[StrictStr] = None type: Optional[StrictStr] = None
message: Optional[StrictStr] = None message: Optional[StrictStr] = None
__properties = ["code", "type", "message"] __properties: ClassVar[List[str]] = ["code", "type", "message"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ArrayOfArrayOfModel(BaseModel):
ArrayOfArrayOfModel ArrayOfArrayOfModel
""" """
another_property: Optional[List[List[Tag]]] = None another_property: Optional[List[List[Tag]]] = None
__properties = ["another_property"] __properties: ClassVar[List[str]] = ["another_property"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ArrayOfArrayOfNumberOnly(BaseModel):
ArrayOfArrayOfNumberOnly ArrayOfArrayOfNumberOnly
""" """
array_array_number: Optional[List[List[float]]] = Field(default=None, alias="ArrayArrayNumber") array_array_number: Optional[List[List[float]]] = Field(default=None, alias="ArrayArrayNumber")
__properties = ["ArrayArrayNumber"] __properties: ClassVar[List[str]] = ["ArrayArrayNumber"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ArrayOfNumberOnly(BaseModel):
ArrayOfNumberOnly ArrayOfNumberOnly
""" """
array_number: Optional[List[float]] = Field(default=None, alias="ArrayNumber") array_number: Optional[List[float]] = Field(default=None, alias="ArrayNumber")
__properties = ["ArrayNumber"] __properties: ClassVar[List[str]] = ["ArrayNumber"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -31,7 +31,7 @@ class ArrayTest(BaseModel):
array_of_string: Optional[Annotated[List[StrictStr], Field(min_length=0, max_length=3)]] = None array_of_string: Optional[Annotated[List[StrictStr], Field(min_length=0, max_length=3)]] = None
array_array_of_integer: Optional[List[List[StrictInt]]] = None array_array_of_integer: Optional[List[List[StrictInt]]] = None
array_array_of_model: Optional[List[List[ReadOnlyFirst]]] = None array_array_of_model: Optional[List[List[ReadOnlyFirst]]] = None
__properties = ["array_of_string", "array_array_of_integer", "array_array_of_model"] __properties: ClassVar[List[str]] = ["array_of_string", "array_array_of_integer", "array_array_of_model"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class BasquePig(BaseModel):
""" """
class_name: StrictStr = Field(alias="className") class_name: StrictStr = Field(alias="className")
color: StrictStr color: StrictStr
__properties = ["className", "color"] __properties: ClassVar[List[str]] = ["className", "color"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -32,7 +32,7 @@ class Capitalization(BaseModel):
capital_snake: Optional[StrictStr] = Field(default=None, alias="Capital_Snake") capital_snake: Optional[StrictStr] = Field(default=None, alias="Capital_Snake")
sca_eth_flow_points: Optional[StrictStr] = Field(default=None, alias="SCA_ETH_Flow_Points") sca_eth_flow_points: Optional[StrictStr] = Field(default=None, alias="SCA_ETH_Flow_Points")
att_name: Optional[StrictStr] = Field(default=None, description="Name of the pet ", alias="ATT_NAME") att_name: Optional[StrictStr] = Field(default=None, description="Name of the pet ", alias="ATT_NAME")
__properties = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"] __properties: ClassVar[List[str]] = ["smallCamel", "CapitalCamel", "small_Snake", "Capital_Snake", "SCA_ETH_Flow_Points", "ATT_NAME"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class Cat(Animal):
Cat Cat
""" """
declawed: Optional[StrictBool] = None declawed: Optional[StrictBool] = None
__properties = ["className", "color", "declawed"] __properties: ClassVar[List[str]] = ["className", "color", "declawed"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class Category(BaseModel):
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: StrictStr name: StrictStr
__properties = ["id", "name"] __properties: ClassVar[List[str]] = ["id", "name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class CircularReferenceModel(BaseModel):
""" """
size: Optional[StrictInt] = None size: Optional[StrictInt] = None
nested: Optional[FirstRef] = None nested: Optional[FirstRef] = None
__properties = ["size", "nested"] __properties: ClassVar[List[str]] = ["size", "nested"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ClassModel(BaseModel):
Model for testing model with \"_class\" property # noqa: E501 Model for testing model with \"_class\" property # noqa: E501
""" """
var_class: Optional[StrictStr] = Field(default=None, alias="_class") var_class: Optional[StrictStr] = Field(default=None, alias="_class")
__properties = ["_class"] __properties: ClassVar[List[str]] = ["_class"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -26,7 +26,7 @@ class Client(BaseModel):
Client Client
""" """
client: Optional[StrictStr] = None client: Optional[StrictStr] = None
__properties = ["client"] __properties: ClassVar[List[str]] = ["client"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class Creature(BaseModel):
""" """
info: CreatureInfo info: CreatureInfo
type: StrictStr type: StrictStr
__properties = ["info", "type"] __properties: ClassVar[List[str]] = ["info", "type"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -26,7 +26,7 @@ class CreatureInfo(BaseModel):
CreatureInfo CreatureInfo
""" """
name: StrictStr name: StrictStr
__properties = ["name"] __properties: ClassVar[List[str]] = ["name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class DanishPig(BaseModel):
""" """
class_name: StrictStr = Field(alias="className") class_name: StrictStr = Field(alias="className")
size: StrictInt size: StrictInt
__properties = ["className", "size"] __properties: ClassVar[List[str]] = ["className", "size"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -26,7 +26,7 @@ class DeprecatedObject(BaseModel):
DeprecatedObject DeprecatedObject
""" """
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
__properties = ["name"] __properties: ClassVar[List[str]] = ["name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class Dog(Animal):
Dog Dog
""" """
breed: Optional[StrictStr] = None breed: Optional[StrictStr] = None
__properties = ["className", "color", "breed"] __properties: ClassVar[List[str]] = ["className", "color", "breed"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class DummyModel(BaseModel):
""" """
category: Optional[StrictStr] = None category: Optional[StrictStr] = None
self_ref: Optional[SelfReferenceModel] = None self_ref: Optional[SelfReferenceModel] = None
__properties = ["category", "self_ref"] __properties: ClassVar[List[str]] = ["category", "self_ref"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class EnumArrays(BaseModel):
""" """
just_symbol: Optional[StrictStr] = None just_symbol: Optional[StrictStr] = None
array_enum: Optional[List[StrictStr]] = None array_enum: Optional[List[StrictStr]] = None
__properties = ["just_symbol", "array_enum"] __properties: ClassVar[List[str]] = ["just_symbol", "array_enum"]
@field_validator('just_symbol') @field_validator('just_symbol')
def just_symbol_validate_enum(cls, value): def just_symbol_validate_enum(cls, value):

View File

@ -39,7 +39,7 @@ class EnumTest(BaseModel):
outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger")
outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=None, alias="outerEnumDefaultValue") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=None, alias="outerEnumDefaultValue")
outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(default=None, alias="outerEnumIntegerDefaultValue") outer_enum_integer_default_value: Optional[OuterEnumIntegerDefaultValue] = Field(default=None, alias="outerEnumIntegerDefaultValue")
__properties = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"] __properties: ClassVar[List[str]] = ["enum_string", "enum_string_required", "enum_integer_default", "enum_integer", "enum_number", "outerEnum", "outerEnumInteger", "outerEnumDefaultValue", "outerEnumIntegerDefaultValue"]
@field_validator('enum_string') @field_validator('enum_string')
def enum_string_validate_enum(cls, value): def enum_string_validate_enum(cls, value):

View File

@ -27,7 +27,7 @@ class File(BaseModel):
Must be named `File` for test. # noqa: E501 Must be named `File` for test. # noqa: E501
""" """
source_uri: Optional[StrictStr] = Field(default=None, description="Test capitalization", alias="sourceURI") source_uri: Optional[StrictStr] = Field(default=None, description="Test capitalization", alias="sourceURI")
__properties = ["sourceURI"] __properties: ClassVar[List[str]] = ["sourceURI"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class FileSchemaTestClass(BaseModel):
""" """
file: Optional[File] = None file: Optional[File] = None
files: Optional[List[File]] = None files: Optional[List[File]] = None
__properties = ["file", "files"] __properties: ClassVar[List[str]] = ["file", "files"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class FirstRef(BaseModel):
""" """
category: Optional[StrictStr] = None category: Optional[StrictStr] = None
self_ref: Optional[SecondRef] = None self_ref: Optional[SecondRef] = None
__properties = ["category", "self_ref"] __properties: ClassVar[List[str]] = ["category", "self_ref"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -26,7 +26,7 @@ class Foo(BaseModel):
Foo Foo
""" """
bar: Optional[StrictStr] = 'bar' bar: Optional[StrictStr] = 'bar'
__properties = ["bar"] __properties: ClassVar[List[str]] = ["bar"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class FooGetDefaultResponse(BaseModel):
FooGetDefaultResponse FooGetDefaultResponse
""" """
string: Optional[Foo] = None string: Optional[Foo] = None
__properties = ["string"] __properties: ClassVar[List[str]] = ["string"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -44,7 +44,7 @@ class FormatTest(BaseModel):
password: Annotated[str, Field(min_length=10, strict=True, max_length=64)] password: Annotated[str, Field(min_length=10, strict=True, max_length=64)]
pattern_with_digits: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string that is a 10 digit number. Can have leading zeros.") pattern_with_digits: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string that is a 10 digit number. Can have leading zeros.")
pattern_with_digits_and_delimiter: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.") pattern_with_digits_and_delimiter: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.")
__properties = ["integer", "int32", "int64", "number", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"] __properties: ClassVar[List[str]] = ["integer", "int32", "int64", "number", "double", "decimal", "string", "string_with_double_quote_pattern", "byte", "binary", "date", "dateTime", "uuid", "password", "pattern_with_digits", "pattern_with_digits_and_delimiter"]
@field_validator('string') @field_validator('string')
def string_validate_regular_expression(cls, value): def string_validate_regular_expression(cls, value):

View File

@ -27,7 +27,7 @@ class HasOnlyReadOnly(BaseModel):
""" """
bar: Optional[StrictStr] = None bar: Optional[StrictStr] = None
foo: Optional[StrictStr] = None foo: Optional[StrictStr] = None
__properties = ["bar", "foo"] __properties: ClassVar[List[str]] = ["bar", "foo"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class HealthCheckResult(BaseModel):
Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. # noqa: E501 Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. # noqa: E501
""" """
nullable_message: Optional[StrictStr] = Field(default=None, alias="NullableMessage") nullable_message: Optional[StrictStr] = Field(default=None, alias="NullableMessage")
__properties = ["NullableMessage"] __properties: ClassVar[List[str]] = ["NullableMessage"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class InnerDictWithProperty(BaseModel):
InnerDictWithProperty InnerDictWithProperty
""" """
a_property: Optional[Union[str, Any]] = Field(default=None, alias="aProperty") a_property: Optional[Union[str, Any]] = Field(default=None, alias="aProperty")
__properties = ["aProperty"] __properties: ClassVar[List[str]] = ["aProperty"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -0,0 +1,74 @@
# 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, StrictStr
from pydantic import Field
class ListClass(BaseModel):
"""
ListClass
"""
var_123_list: Optional[StrictStr] = Field(default=None, alias="123-list")
__properties: ClassVar[List[str]] = ["123-list"]
model_config = {
"populate_by_name": True,
"validate_assignment": True
}
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) -> ListClass:
"""Create an instance of ListClass 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.model_dump(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> ListClass:
"""Create an instance of ListClass from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return ListClass.model_validate(obj)
_obj = ListClass.model_validate({
"123-list": obj.get("123-list")
})
return _obj

View File

@ -28,7 +28,7 @@ class MapOfArrayOfModel(BaseModel):
MapOfArrayOfModel MapOfArrayOfModel
""" """
shop_id_to_org_online_lip_map: Optional[Dict[str, List[Tag]]] = Field(default=None, alias="shopIdToOrgOnlineLipMap") shop_id_to_org_online_lip_map: Optional[Dict[str, List[Tag]]] = Field(default=None, alias="shopIdToOrgOnlineLipMap")
__properties = ["shopIdToOrgOnlineLipMap"] __properties: ClassVar[List[str]] = ["shopIdToOrgOnlineLipMap"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -29,7 +29,7 @@ class MapTest(BaseModel):
map_of_enum_string: Optional[Dict[str, StrictStr]] = None map_of_enum_string: Optional[Dict[str, StrictStr]] = None
direct_map: Optional[Dict[str, StrictBool]] = None direct_map: Optional[Dict[str, StrictBool]] = None
indirect_map: Optional[Dict[str, StrictBool]] = None indirect_map: Optional[Dict[str, StrictBool]] = None
__properties = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] __properties: ClassVar[List[str]] = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"]
@field_validator('map_of_enum_string') @field_validator('map_of_enum_string')
def map_of_enum_string_validate_enum(cls, value): def map_of_enum_string_validate_enum(cls, value):

View File

@ -30,7 +30,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
uuid: Optional[StrictStr] = None uuid: Optional[StrictStr] = None
date_time: Optional[datetime] = Field(default=None, alias="dateTime") date_time: Optional[datetime] = Field(default=None, alias="dateTime")
map: Optional[Dict[str, Animal]] = None map: Optional[Dict[str, Animal]] = None
__properties = ["uuid", "dateTime", "map"] __properties: ClassVar[List[str]] = ["uuid", "dateTime", "map"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class Model200Response(BaseModel):
""" """
name: Optional[StrictInt] = None name: Optional[StrictInt] = None
var_class: Optional[StrictStr] = Field(default=None, alias="class") var_class: Optional[StrictStr] = Field(default=None, alias="class")
__properties = ["name", "class"] __properties: ClassVar[List[str]] = ["name", "class"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ModelReturn(BaseModel):
Model for testing reserved words # noqa: E501 Model for testing reserved words # noqa: E501
""" """
var_return: Optional[StrictInt] = Field(default=None, alias="return") var_return: Optional[StrictInt] = Field(default=None, alias="return")
__properties = ["return"] __properties: ClassVar[List[str]] = ["return"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -30,7 +30,7 @@ class Name(BaseModel):
snake_case: Optional[StrictInt] = None snake_case: Optional[StrictInt] = None
var_property: Optional[StrictStr] = Field(default=None, alias="property") var_property: Optional[StrictStr] = Field(default=None, alias="property")
var_123_number: Optional[StrictInt] = Field(default=None, alias="123Number") var_123_number: Optional[StrictInt] = Field(default=None, alias="123Number")
__properties = ["name", "snake_case", "property", "123Number"] __properties: ClassVar[List[str]] = ["name", "snake_case", "property", "123Number"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -39,7 +39,7 @@ class NullableClass(BaseModel):
object_and_items_nullable_prop: Optional[Dict[str, Union[str, Any]]] = None object_and_items_nullable_prop: Optional[Dict[str, Union[str, Any]]] = None
object_items_nullable: Optional[Dict[str, Union[str, Any]]] = None object_items_nullable: Optional[Dict[str, Union[str, Any]]] = None
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
__properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] __properties: ClassVar[List[str]] = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -156,7 +156,7 @@ class NullableClass(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -29,7 +29,7 @@ class NullableProperty(BaseModel):
""" """
id: StrictInt id: StrictInt
name: Optional[Annotated[str, Field(strict=True)]] name: Optional[Annotated[str, Field(strict=True)]]
__properties = ["id", "name"] __properties: ClassVar[List[str]] = ["id", "name"]
@field_validator('name') @field_validator('name')
def name_validate_regular_expression(cls, value): def name_validate_regular_expression(cls, value):

View File

@ -27,7 +27,7 @@ class NumberOnly(BaseModel):
NumberOnly NumberOnly
""" """
just_number: Optional[float] = Field(default=None, alias="JustNumber") just_number: Optional[float] = Field(default=None, alias="JustNumber")
__properties = ["JustNumber"] __properties: ClassVar[List[str]] = ["JustNumber"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ObjectToTestAdditionalProperties(BaseModel):
Minimal object # noqa: E501 Minimal object # noqa: E501
""" """
var_property: Optional[StrictBool] = Field(default=False, description="Property", alias="property") var_property: Optional[StrictBool] = Field(default=False, description="Property", alias="property")
__properties = ["property"] __properties: ClassVar[List[str]] = ["property"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -31,7 +31,7 @@ class ObjectWithDeprecatedFields(BaseModel):
id: Optional[float] = None id: Optional[float] = None
deprecated_ref: Optional[DeprecatedObject] = Field(default=None, alias="deprecatedRef") deprecated_ref: Optional[DeprecatedObject] = Field(default=None, alias="deprecatedRef")
bars: Optional[List[StrictStr]] = None bars: Optional[List[StrictStr]] = None
__properties = ["uuid", "id", "deprecatedRef", "bars"] __properties: ClassVar[List[str]] = ["uuid", "id", "deprecatedRef", "bars"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -32,7 +32,7 @@ class Order(BaseModel):
ship_date: Optional[datetime] = Field(default=None, alias="shipDate") ship_date: Optional[datetime] = Field(default=None, alias="shipDate")
status: Optional[StrictStr] = Field(default=None, description="Order Status") status: Optional[StrictStr] = Field(default=None, description="Order Status")
complete: Optional[StrictBool] = False complete: Optional[StrictBool] = False
__properties = ["id", "petId", "quantity", "shipDate", "status", "complete"] __properties: ClassVar[List[str]] = ["id", "petId", "quantity", "shipDate", "status", "complete"]
@field_validator('status') @field_validator('status')
def status_validate_enum(cls, value): def status_validate_enum(cls, value):

View File

@ -28,7 +28,7 @@ class OuterComposite(BaseModel):
my_number: Optional[float] = None my_number: Optional[float] = None
my_string: Optional[StrictStr] = None my_string: Optional[StrictStr] = None
my_boolean: Optional[StrictBool] = None my_boolean: Optional[StrictBool] = None
__properties = ["my_number", "my_string", "my_boolean"] __properties: ClassVar[List[str]] = ["my_number", "my_string", "my_boolean"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -29,7 +29,7 @@ class OuterObjectWithEnumProperty(BaseModel):
""" """
str_value: Optional[OuterEnum] = None str_value: Optional[OuterEnum] = None
value: OuterEnumInteger value: OuterEnumInteger
__properties = ["str_value", "value"] __properties: ClassVar[List[str]] = ["str_value", "value"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class Parent(BaseModel):
Parent Parent
""" """
optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict") optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict")
__properties = ["optionalDict"] __properties: ClassVar[List[str]] = ["optionalDict"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class ParentWithOptionalDict(BaseModel):
ParentWithOptionalDict ParentWithOptionalDict
""" """
optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict") optional_dict: Optional[Dict[str, InnerDictWithProperty]] = Field(default=None, alias="optionalDict")
__properties = ["optionalDict"] __properties: ClassVar[List[str]] = ["optionalDict"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -35,7 +35,7 @@ class Pet(BaseModel):
photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls")
tags: Optional[List[Tag]] = None tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(default=None, description="pet status in the store") status: Optional[StrictStr] = Field(default=None, description="pet status in the store")
__properties = ["id", "category", "name", "photoUrls", "tags", "status"] __properties: ClassVar[List[str]] = ["id", "category", "name", "photoUrls", "tags", "status"]
@field_validator('status') @field_validator('status')
def status_validate_enum(cls, value): def status_validate_enum(cls, value):

View File

@ -29,7 +29,7 @@ class PropertyNameCollision(BaseModel):
type: Optional[StrictStr] = Field(default=None, alias="_type") type: Optional[StrictStr] = Field(default=None, alias="_type")
type: Optional[StrictStr] = None type: Optional[StrictStr] = None
type_: Optional[StrictStr] = None type_: Optional[StrictStr] = None
__properties = ["_type", "type", "type_"] __properties: ClassVar[List[str]] = ["_type", "type", "type_"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class ReadOnlyFirst(BaseModel):
""" """
bar: Optional[StrictStr] = None bar: Optional[StrictStr] = None
baz: Optional[StrictStr] = None baz: Optional[StrictStr] = None
__properties = ["bar", "baz"] __properties: ClassVar[List[str]] = ["bar", "baz"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class SecondRef(BaseModel):
""" """
category: Optional[StrictStr] = None category: Optional[StrictStr] = None
circular_ref: Optional[CircularReferenceModel] = None circular_ref: Optional[CircularReferenceModel] = None
__properties = ["category", "circular_ref"] __properties: ClassVar[List[str]] = ["category", "circular_ref"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class SelfReferenceModel(BaseModel):
""" """
size: Optional[StrictInt] = None size: Optional[StrictInt] = None
nested: Optional[DummyModel] = None nested: Optional[DummyModel] = None
__properties = ["size", "nested"] __properties: ClassVar[List[str]] = ["size", "nested"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -27,7 +27,7 @@ class SpecialModelName(BaseModel):
SpecialModelName SpecialModelName
""" """
special_property_name: Optional[StrictInt] = Field(default=None, alias="$special[property.name]") special_property_name: Optional[StrictInt] = Field(default=None, alias="$special[property.name]")
__properties = ["$special[property.name]"] __properties: ClassVar[List[str]] = ["$special[property.name]"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -30,7 +30,7 @@ class SpecialName(BaseModel):
var_property: Optional[StrictInt] = Field(default=None, alias="property") var_property: Optional[StrictInt] = Field(default=None, alias="property")
var_async: Optional[Category] = Field(default=None, alias="async") var_async: Optional[Category] = Field(default=None, alias="async")
var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema")
__properties = ["property", "async", "schema"] __properties: ClassVar[List[str]] = ["property", "async", "schema"]
@field_validator('var_schema') @field_validator('var_schema')
def var_schema_validate_enum(cls, value): def var_schema_validate_enum(cls, value):

View File

@ -27,7 +27,7 @@ class Tag(BaseModel):
""" """
id: Optional[StrictInt] = None id: Optional[StrictInt] = None
name: Optional[StrictStr] = None name: Optional[StrictStr] = None
__properties = ["id", "name"] __properties: ClassVar[List[str]] = ["id", "name"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -28,7 +28,7 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
""" """
some_property: Optional[StrictStr] = Field(default=None, alias="someProperty") some_property: Optional[StrictStr] = Field(default=None, alias="someProperty")
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
__properties = ["someProperty"] __properties: ClassVar[List[str]] = ["someProperty"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,
@ -78,7 +78,7 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
}) })
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties.default: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -26,7 +26,7 @@ class Tiger(BaseModel):
Tiger Tiger
""" """
skill: Optional[StrictStr] = None skill: Optional[StrictStr] = None
__properties = ["skill"] __properties: ClassVar[List[str]] = ["skill"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -34,7 +34,7 @@ class User(BaseModel):
password: Optional[StrictStr] = None password: Optional[StrictStr] = None
phone: Optional[StrictStr] = None phone: Optional[StrictStr] = None
user_status: Optional[StrictInt] = Field(default=None, description="User Status", alias="userStatus") user_status: Optional[StrictInt] = Field(default=None, description="User Status", alias="userStatus")
__properties = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"] __properties: ClassVar[List[str]] = ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

View File

@ -30,7 +30,7 @@ class WithNestedOneOf(BaseModel):
size: Optional[StrictInt] = None size: Optional[StrictInt] = None
nested_pig: Optional[Pig] = None nested_pig: Optional[Pig] = None
nested_oneof_enum_string: Optional[OneOfEnumString] = None nested_oneof_enum_string: Optional[OneOfEnumString] = None
__properties = ["size", "nested_pig", "nested_oneof_enum_string"] __properties: ClassVar[List[str]] = ["size", "nested_pig", "nested_oneof_enum_string"]
model_config = { model_config = {
"populate_by_name": True, "populate_by_name": True,

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.list_class import ListClass # noqa: E501
class TestListClass(unittest.TestCase):
"""ListClass unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> ListClass:
"""Test ListClass
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 `ListClass`
"""
model = ListClass() # noqa: E501
if include_optional:
return ListClass(
var_123_list = ''
)
else:
return ListClass(
)
"""
def testListClass(self):
"""Test ListClass"""
# 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

@ -49,7 +49,7 @@ docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md docs/HealthCheckResult.md
docs/InnerDictWithProperty.md docs/InnerDictWithProperty.md
docs/IntOrString.md docs/IntOrString.md
docs/List.md docs/ListClass.md
docs/MapOfArrayOfModel.md docs/MapOfArrayOfModel.md
docs/MapTest.md docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/MixedPropertiesAndAdditionalPropertiesClass.md
@ -146,7 +146,7 @@ petstore_api/models/has_only_read_only.py
petstore_api/models/health_check_result.py petstore_api/models/health_check_result.py
petstore_api/models/inner_dict_with_property.py petstore_api/models/inner_dict_with_property.py
petstore_api/models/int_or_string.py petstore_api/models/int_or_string.py
petstore_api/models/list.py petstore_api/models/list_class.py
petstore_api/models/map_of_array_of_model.py petstore_api/models/map_of_array_of_model.py
petstore_api/models/map_test.py petstore_api/models/map_test.py
petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/mixed_properties_and_additional_properties_class.py

View File

@ -177,7 +177,7 @@ Class | Method | HTTP request | Description
- [HealthCheckResult](docs/HealthCheckResult.md) - [HealthCheckResult](docs/HealthCheckResult.md)
- [InnerDictWithProperty](docs/InnerDictWithProperty.md) - [InnerDictWithProperty](docs/InnerDictWithProperty.md)
- [IntOrString](docs/IntOrString.md) - [IntOrString](docs/IntOrString.md)
- [List](docs/List.md) - [ListClass](docs/ListClass.md)
- [MapOfArrayOfModel](docs/MapOfArrayOfModel.md) - [MapOfArrayOfModel](docs/MapOfArrayOfModel.md)
- [MapTest](docs/MapTest.md) - [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)

View File

@ -0,0 +1,28 @@
# ListClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**var_123_list** | **str** | | [optional]
## Example
```python
from petstore_api.models.list_class import ListClass
# TODO update the JSON string below
json = "{}"
# create an instance of ListClass from a JSON string
list_class_instance = ListClass.from_json(json)
# print the JSON string representation of the object
print ListClass.to_json()
# convert the object into a dict
list_class_dict = list_class_instance.to_dict()
# create an instance of ListClass from a dict
list_class_form_dict = list_class.from_dict(list_class_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

@ -80,7 +80,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -56,7 +56,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -0,0 +1,71 @@
# 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, Field, StrictStr
class ListClass(BaseModel):
"""
ListClass
"""
var_123_list: Optional[StrictStr] = Field(None, alias="123-list")
__properties = ["123-list"]
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) -> ListClass:
"""Create an instance of ListClass 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) -> ListClass:
"""Create an instance of ListClass from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return ListClass.parse_obj(obj)
_obj = ListClass.parse_obj({
"var_123_list": obj.get("123-list")
})
return _obj

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.list_class import ListClass # noqa: E501
class TestListClass(unittest.TestCase):
"""ListClass unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> ListClass:
"""Test ListClass
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 `ListClass`
"""
model = ListClass() # noqa: E501
if include_optional:
return ListClass(
var_123_list = ''
)
else:
return ListClass(
)
"""
def testListClass(self):
"""Test ListClass"""
# 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

@ -173,7 +173,7 @@ class ModelTests(unittest.TestCase):
def test_list(self): def test_list(self):
# should throw exception as var_123_list should be string # should throw exception as var_123_list should be string
try: try:
l3 = petstore_api.List(var_123_list=123) l3 = petstore_api.ListClass(var_123_list=123)
self.assertTrue(False) # this line shouldn't execute self.assertTrue(False) # this line shouldn't execute
except ValueError as e: except ValueError as e:
#error_message = ( #error_message = (
@ -182,13 +182,13 @@ class ModelTests(unittest.TestCase):
# " str type expected (type=type_error.str)\n") # " str type expected (type=type_error.str)\n")
self.assertTrue("str type expected" in str(e)) self.assertTrue("str type expected" in str(e))
l = petstore_api.List(var_123_list="bulldog") l = petstore_api.ListClass(var_123_list="bulldog")
self.assertEqual(l.to_json(), '{"123-list": "bulldog"}') self.assertEqual(l.to_json(), '{"123-list": "bulldog"}')
self.assertEqual(l.to_dict(), {'123-list': 'bulldog'}) self.assertEqual(l.to_dict(), {'123-list': 'bulldog'})
l2 = petstore_api.List.from_json(l.to_json()) l2 = petstore_api.ListClass.from_json(l.to_json())
self.assertEqual(l2.var_123_list, 'bulldog') self.assertEqual(l2.var_123_list, 'bulldog')
self.assertTrue(isinstance(l2, petstore_api.List)) self.assertTrue(isinstance(l2, petstore_api.ListClass))
def test_enum_ref_property(self): def test_enum_ref_property(self):
# test enum ref property # test enum ref property

View File

@ -49,7 +49,7 @@ docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md docs/HealthCheckResult.md
docs/InnerDictWithProperty.md docs/InnerDictWithProperty.md
docs/IntOrString.md docs/IntOrString.md
docs/List.md docs/ListClass.md
docs/MapOfArrayOfModel.md docs/MapOfArrayOfModel.md
docs/MapTest.md docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/MixedPropertiesAndAdditionalPropertiesClass.md
@ -146,7 +146,7 @@ petstore_api/models/has_only_read_only.py
petstore_api/models/health_check_result.py petstore_api/models/health_check_result.py
petstore_api/models/inner_dict_with_property.py petstore_api/models/inner_dict_with_property.py
petstore_api/models/int_or_string.py petstore_api/models/int_or_string.py
petstore_api/models/list.py petstore_api/models/list_class.py
petstore_api/models/map_of_array_of_model.py petstore_api/models/map_of_array_of_model.py
petstore_api/models/map_test.py petstore_api/models/map_test.py
petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/mixed_properties_and_additional_properties_class.py

View File

@ -177,7 +177,7 @@ Class | Method | HTTP request | Description
- [HealthCheckResult](docs/HealthCheckResult.md) - [HealthCheckResult](docs/HealthCheckResult.md)
- [InnerDictWithProperty](docs/InnerDictWithProperty.md) - [InnerDictWithProperty](docs/InnerDictWithProperty.md)
- [IntOrString](docs/IntOrString.md) - [IntOrString](docs/IntOrString.md)
- [List](docs/List.md) - [ListClass](docs/ListClass.md)
- [MapOfArrayOfModel](docs/MapOfArrayOfModel.md) - [MapOfArrayOfModel](docs/MapOfArrayOfModel.md)
- [MapTest](docs/MapTest.md) - [MapTest](docs/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)

View File

@ -0,0 +1,28 @@
# ListClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**var_123_list** | **str** | | [optional]
## Example
```python
from petstore_api.models.list_class import ListClass
# TODO update the JSON string below
json = "{}"
# create an instance of ListClass from a JSON string
list_class_instance = ListClass.from_json(json)
# print the JSON string representation of the object
print ListClass.to_json()
# convert the object into a dict
list_class_dict = list_class_instance.to_dict()
# create an instance of ListClass from a dict
list_class_form_dict = list_class.from_dict(list_class_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

@ -80,7 +80,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -56,7 +56,7 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly
from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.health_check_result import HealthCheckResult
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
from petstore_api.models.int_or_string import IntOrString from petstore_api.models.int_or_string import IntOrString
from petstore_api.models.list import List from petstore_api.models.list_class import ListClass
from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
from petstore_api.models.map_test import MapTest from petstore_api.models.map_test import MapTest
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@ -0,0 +1,83 @@
# 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, Field, StrictStr
class ListClass(BaseModel):
"""
ListClass
"""
var_123_list: Optional[StrictStr] = Field(None, alias="123-list")
additional_properties: Dict[str, Any] = {}
__properties = ["123-list"]
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) -> ListClass:
"""Create an instance of ListClass 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) -> ListClass:
"""Create an instance of ListClass from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return ListClass.parse_obj(obj)
_obj = ListClass.parse_obj({
"var_123_list": obj.get("123-list")
})
# 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

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.list_class import ListClass # noqa: E501
class TestListClass(unittest.TestCase):
"""ListClass unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> ListClass:
"""Test ListClass
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 `ListClass`
"""
model = ListClass() # noqa: E501
if include_optional:
return ListClass(
var_123_list = ''
)
else:
return ListClass(
)
"""
def testListClass(self):
"""Test ListClass"""
# 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

@ -316,7 +316,7 @@ class ModelTests(unittest.TestCase):
def test_list(self): def test_list(self):
# should throw exception as var_123_list should be string # should throw exception as var_123_list should be string
try: try:
l3 = petstore_api.List(var_123_list=123) l3 = petstore_api.ListClass(var_123_list=123)
self.assertTrue(False) # this line shouldn't execute self.assertTrue(False) # this line shouldn't execute
except ValueError as e: except ValueError as e:
#error_message = ( #error_message = (
@ -325,13 +325,13 @@ class ModelTests(unittest.TestCase):
# " str type expected (type=type_error.str)\n") # " str type expected (type=type_error.str)\n")
self.assertTrue("str type expected" in str(e)) self.assertTrue("str type expected" in str(e))
l = petstore_api.List(var_123_list="bulldog") l = petstore_api.ListClass(var_123_list="bulldog")
self.assertEqual(l.to_json(), '{"123-list": "bulldog"}') self.assertEqual(l.to_json(), '{"123-list": "bulldog"}')
self.assertEqual(l.to_dict(), {'123-list': 'bulldog'}) self.assertEqual(l.to_dict(), {'123-list': 'bulldog'})
l2 = petstore_api.List.from_json(l.to_json()) l2 = petstore_api.ListClass.from_json(l.to_json())
self.assertEqual(l2.var_123_list, 'bulldog') self.assertEqual(l2.var_123_list, 'bulldog')
self.assertTrue(isinstance(l2, petstore_api.List)) self.assertTrue(isinstance(l2, petstore_api.ListClass))
def test_enum_ref_property(self): def test_enum_ref_property(self):
# test enum ref property # test enum ref property

View File

@ -49,7 +49,7 @@ docs/HasOnlyReadOnly.md
docs/HealthCheckResult.md docs/HealthCheckResult.md
docs/InnerDictWithProperty.md docs/InnerDictWithProperty.md
docs/IntOrString.md docs/IntOrString.md
docs/List.md docs/ListClass.md
docs/MapOfArrayOfModel.md docs/MapOfArrayOfModel.md
docs/MapTest.md docs/MapTest.md
docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/MixedPropertiesAndAdditionalPropertiesClass.md
@ -146,7 +146,7 @@ petstore_api/models/has_only_read_only.py
petstore_api/models/health_check_result.py petstore_api/models/health_check_result.py
petstore_api/models/inner_dict_with_property.py petstore_api/models/inner_dict_with_property.py
petstore_api/models/int_or_string.py petstore_api/models/int_or_string.py
petstore_api/models/list.py petstore_api/models/list_class.py
petstore_api/models/map_of_array_of_model.py petstore_api/models/map_of_array_of_model.py
petstore_api/models/map_test.py petstore_api/models/map_test.py
petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/mixed_properties_and_additional_properties_class.py

Some files were not shown because too many files have changed in this diff Show More