forked from loafle/openapi-generator-original
python: adjust basic typing information (#17511)
* python: adjust basic typing information This is an initial pass to fix and adjust the typing information for the generated client. This is enough to have mypy runnning without complains on all the (modern) generated clients (Pydantic v1 code is not checked for instance) mypy is also now run directly in the CI, so further changes will also be checked and thus, will need to be compliant with good typing information. Note that this doesn't *fully* type all the code: mypy is not run in "strict" mode and there are still many functions/methods/attributes which are still not fully typed, but it's a first good step in that direction. * ApiResponse's raw_data can't be None * Fix indentation * Revert test changes * run mypy on tests/ directory * don't forcefully convert the client response headers to dict * override petstore ApiResponse model * adjust type of 'any/one_of_schemas' fields
This commit is contained in:
@@ -12,7 +12,6 @@ docs/Animal.md
|
||||
docs/AnotherFakeApi.md
|
||||
docs/AnyOfColor.md
|
||||
docs/AnyOfPig.md
|
||||
docs/ApiResponse.md
|
||||
docs/ArrayOfArrayOfModel.md
|
||||
docs/ArrayOfArrayOfNumberOnly.md
|
||||
docs/ArrayOfNumberOnly.md
|
||||
@@ -54,6 +53,7 @@ docs/MapOfArrayOfModel.md
|
||||
docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
docs/ModelApiResponse.md
|
||||
docs/ModelReturn.md
|
||||
docs/Name.md
|
||||
docs/NullableClass.md
|
||||
@@ -116,7 +116,6 @@ petstore_api/models/all_of_with_single_ref.py
|
||||
petstore_api/models/animal.py
|
||||
petstore_api/models/any_of_color.py
|
||||
petstore_api/models/any_of_pig.py
|
||||
petstore_api/models/api_response.py
|
||||
petstore_api/models/array_of_array_of_model.py
|
||||
petstore_api/models/array_of_array_of_number_only.py
|
||||
petstore_api/models/array_of_number_only.py
|
||||
@@ -155,6 +154,7 @@ petstore_api/models/map_of_array_of_model.py
|
||||
petstore_api/models/map_test.py
|
||||
petstore_api/models/mixed_properties_and_additional_properties_class.py
|
||||
petstore_api/models/model200_response.py
|
||||
petstore_api/models/model_api_response.py
|
||||
petstore_api/models/model_return.py
|
||||
petstore_api/models/name.py
|
||||
petstore_api/models/nullable_class.py
|
||||
|
||||
@@ -146,7 +146,6 @@ Class | Method | HTTP request | Description
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnyOfColor](docs/AnyOfColor.md)
|
||||
- [AnyOfPig](docs/AnyOfPig.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
@@ -185,6 +184,7 @@ Class | Method | HTTP request | Description
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NullableClass](docs/NullableClass.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# ApiResponse
|
||||
# ModelApiResponse
|
||||
|
||||
|
||||
## Properties
|
||||
@@ -12,19 +12,19 @@ Name | Type | Description | Notes
|
||||
## Example
|
||||
|
||||
```python
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
|
||||
# TODO update the JSON string below
|
||||
json = "{}"
|
||||
# create an instance of ApiResponse from a JSON string
|
||||
api_response_instance = ApiResponse.from_json(json)
|
||||
# create an instance of ModelApiResponse from a JSON string
|
||||
model_api_response_instance = ModelApiResponse.from_json(json)
|
||||
# print the JSON string representation of the object
|
||||
print ApiResponse.to_json()
|
||||
print ModelApiResponse.to_json()
|
||||
|
||||
# convert the object into a dict
|
||||
api_response_dict = api_response_instance.to_dict()
|
||||
# create an instance of ApiResponse from a dict
|
||||
api_response_form_dict = api_response.from_dict(api_response_dict)
|
||||
model_api_response_dict = model_api_response_instance.to_dict()
|
||||
# create an instance of ModelApiResponse from a dict
|
||||
model_api_response_form_dict = model_api_response.from_dict(model_api_response_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)
|
||||
|
||||
@@ -803,7 +803,7 @@ void (empty response body)
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **upload_file**
|
||||
> ApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file)
|
||||
> ModelApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file)
|
||||
|
||||
uploads an image
|
||||
|
||||
@@ -815,7 +815,7 @@ uploads an image
|
||||
|
||||
```python
|
||||
import petstore_api
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
@@ -862,7 +862,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
[**ModelApiResponse**](ModelApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -882,7 +882,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **upload_file_with_required_file**
|
||||
> ApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
|
||||
> ModelApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata)
|
||||
|
||||
uploads an image (required)
|
||||
|
||||
@@ -894,7 +894,7 @@ uploads an image (required)
|
||||
|
||||
```python
|
||||
import petstore_api
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
|
||||
@@ -941,7 +941,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
[**ModelApiResponse**](ModelApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**underscore_type** | **str** | | [optional]
|
||||
**type** | **str** | | [optional]
|
||||
**type** | **str** | | [optional]
|
||||
**type_** | **str** | | [optional]
|
||||
**type_with_underscore** | **str** | | [optional]
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
from petstore_api.models.any_of_color import AnyOfColor
|
||||
from petstore_api.models.any_of_pig import AnyOfPig
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
@@ -85,6 +84,7 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
|
||||
from petstore_api.models.map_test import MapTest
|
||||
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
|
||||
from petstore_api.models.model200_response import Model200Response
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
from petstore_api.models.model_return import ModelReturn
|
||||
from petstore_api.models.name import Name
|
||||
from petstore_api.models.nullable_class import NullableClass
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field
|
||||
from typing_extensions import Annotated
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
||||
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, field_validator
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field
|
||||
from typing_extensions import Annotated
|
||||
|
||||
@@ -14,16 +14,12 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field, StrictBytes, StrictInt, StrictStr, field_validator
|
||||
from typing import List, Optional, Union
|
||||
from typing_extensions import Annotated
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
from petstore_api.models.pet import Pet
|
||||
|
||||
from petstore_api.api_client import ApiClient
|
||||
@@ -1976,7 +1972,7 @@ class PetApi:
|
||||
_content_type: Optional[StrictStr] = None,
|
||||
_headers: Optional[Dict[StrictStr, Any]] = None,
|
||||
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
||||
) -> ApiResponse:
|
||||
) -> ModelApiResponse:
|
||||
"""uploads an image
|
||||
|
||||
|
||||
@@ -2020,7 +2016,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
@@ -2051,7 +2047,7 @@ class PetApi:
|
||||
_content_type: Optional[StrictStr] = None,
|
||||
_headers: Optional[Dict[StrictStr, Any]] = None,
|
||||
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
||||
) -> ApiResponse[ApiResponse]:
|
||||
) -> ApiResponse[ModelApiResponse]:
|
||||
"""uploads an image
|
||||
|
||||
|
||||
@@ -2095,7 +2091,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
@@ -2170,7 +2166,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
@@ -2277,7 +2273,7 @@ class PetApi:
|
||||
_content_type: Optional[StrictStr] = None,
|
||||
_headers: Optional[Dict[StrictStr, Any]] = None,
|
||||
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
||||
) -> ApiResponse:
|
||||
) -> ModelApiResponse:
|
||||
"""uploads an image (required)
|
||||
|
||||
|
||||
@@ -2321,7 +2317,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
@@ -2352,7 +2348,7 @@ class PetApi:
|
||||
_content_type: Optional[StrictStr] = None,
|
||||
_headers: Optional[Dict[StrictStr, Any]] = None,
|
||||
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
|
||||
) -> ApiResponse[ApiResponse]:
|
||||
) -> ApiResponse[ModelApiResponse]:
|
||||
"""uploads an image (required)
|
||||
|
||||
|
||||
@@ -2396,7 +2392,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
@@ -2471,7 +2467,7 @@ class PetApi:
|
||||
)
|
||||
|
||||
_response_types_map: Dict[str, Optional[str]] = {
|
||||
'200': "ApiResponse",
|
||||
'200': "ModelApiResponse",
|
||||
}
|
||||
response_data = await self.api_client.call_api(
|
||||
*_param,
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field, StrictStr
|
||||
from typing_extensions import Annotated
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
import warnings
|
||||
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
from typing import Annotated
|
||||
except ImportError:
|
||||
from typing_extensions import Annotated
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from pydantic import Field, StrictStr
|
||||
from typing import List
|
||||
|
||||
@@ -275,15 +275,13 @@ class ApiClient:
|
||||
)
|
||||
|
||||
except ApiException as e:
|
||||
if e.body:
|
||||
e.body = e.body.decode('utf-8')
|
||||
raise e
|
||||
|
||||
return response_data
|
||||
|
||||
def response_deserialize(
|
||||
self,
|
||||
response_data: rest.RESTResponse = None,
|
||||
response_data: rest.RESTResponse,
|
||||
response_types_map=None
|
||||
) -> ApiResponse:
|
||||
"""Deserializes response into an object.
|
||||
@@ -292,6 +290,8 @@ class ApiClient:
|
||||
:return: ApiResponse
|
||||
"""
|
||||
|
||||
msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
|
||||
assert response_data.data is not None, msg
|
||||
|
||||
response_type = response_types_map.get(str(response_data.status), None)
|
||||
if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""API response object."""
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Dict, Optional, Generic, TypeVar
|
||||
from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel
|
||||
from typing import Optional, Generic, Mapping, TypeVar
|
||||
from pydantic import Field, StrictInt, StrictBytes, BaseModel
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]):
|
||||
"""
|
||||
|
||||
status_code: StrictInt = Field(description="HTTP status code")
|
||||
headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers")
|
||||
headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
|
||||
data: T = Field(description="Deserialized data given the data type")
|
||||
raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
""" # noqa: E501
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from typing_extensions import Self
|
||||
|
||||
class OpenApiException(Exception):
|
||||
|
||||
@@ -22,7 +22,6 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
|
||||
from petstore_api.models.animal import Animal
|
||||
from petstore_api.models.any_of_color import AnyOfColor
|
||||
from petstore_api.models.any_of_pig import AnyOfPig
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel
|
||||
from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||
@@ -61,6 +60,7 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel
|
||||
from petstore_api.models.map_test import MapTest
|
||||
from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
|
||||
from petstore_api.models.model200_response import Model200Response
|
||||
from petstore_api.models.model_api_response import ModelApiResponse
|
||||
from petstore_api.models.model_return import ModelReturn
|
||||
from petstore_api.models.name import Name
|
||||
from petstore_api.models.nullable_class import NullableClass
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class AdditionalPropertiesAnyType(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class AdditionalPropertiesAnyType(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesAnyType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,11 +62,13 @@ class AdditionalPropertiesAnyType(BaseModel):
|
||||
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={
|
||||
"additional_properties",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
@@ -79,7 +79,7 @@ class AdditionalPropertiesAnyType(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesAnyType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class AdditionalPropertiesClass(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class AdditionalPropertiesClass(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesClass from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class AdditionalPropertiesClass(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesClass from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class AdditionalPropertiesObject(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class AdditionalPropertiesObject(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesObject from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,11 +62,13 @@ class AdditionalPropertiesObject(BaseModel):
|
||||
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={
|
||||
"additional_properties",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
@@ -79,7 +79,7 @@ class AdditionalPropertiesObject(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesObject from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class AdditionalPropertiesWithDescriptionOnly(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,11 +62,13 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
|
||||
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={
|
||||
"additional_properties",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
@@ -79,7 +79,7 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.single_ref_type import SingleRefType
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class AllOfWithSingleRef(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class AllOfWithSingleRef(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AllOfWithSingleRef from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class AllOfWithSingleRef(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of AllOfWithSingleRef from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Animal(BaseModel):
|
||||
"""
|
||||
@@ -40,7 +38,7 @@ class Animal(BaseModel):
|
||||
|
||||
|
||||
# JSON field name that stores the object type
|
||||
__discriminator_property_name: ClassVar[List[str]] = 'className'
|
||||
__discriminator_property_name: ClassVar[str] = 'className'
|
||||
|
||||
# discriminator mappings
|
||||
__discriminator_value_class_map: ClassVar[Dict[str, str]] = {
|
||||
@@ -48,7 +46,7 @@ class Animal(BaseModel):
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def get_discriminator_value(cls, obj: Dict) -> str:
|
||||
def get_discriminator_value(cls, obj: Dict) -> Optional[str]:
|
||||
"""Returns the discriminator value (object type) of the data"""
|
||||
discriminator_value = obj[cls.__discriminator_property_name]
|
||||
if discriminator_value:
|
||||
@@ -66,7 +64,7 @@ class Animal(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Union[Self, Self]:
|
||||
def from_json(cls, json_str: str) -> Optional[Union[Self, Self]]:
|
||||
"""Create an instance of Animal from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -80,16 +78,18 @@ class Animal(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Union[Self, Self]:
|
||||
def from_dict(cls, obj: Dict) -> Optional[Union[Self, Self]]:
|
||||
"""Create an instance of Animal from a dict"""
|
||||
# look up the object type based on discriminator mapping
|
||||
object_type = cls.get_discriminator_value(obj)
|
||||
|
||||
@@ -22,6 +22,7 @@ from typing import List, Optional
|
||||
from typing_extensions import Annotated
|
||||
from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
|
||||
from typing_extensions import Literal, Self
|
||||
from pydantic import Field
|
||||
|
||||
ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"]
|
||||
|
||||
@@ -40,7 +41,7 @@ class AnyOfColor(BaseModel):
|
||||
actual_instance: Optional[Union[List[int], str]] = None
|
||||
else:
|
||||
actual_instance: Any = None
|
||||
any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS]
|
||||
any_of_schemas: List[str] = Field(default=Literal["List[int]", "str"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -133,22 +134,20 @@ class AnyOfColor(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, List[int], str]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
return None
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
return self.actual_instance
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the actual instance"""
|
||||
|
||||
@@ -23,6 +23,7 @@ from petstore_api.models.basque_pig import BasquePig
|
||||
from petstore_api.models.danish_pig import DanishPig
|
||||
from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict
|
||||
from typing_extensions import Literal, Self
|
||||
from pydantic import Field
|
||||
|
||||
ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"]
|
||||
|
||||
@@ -39,7 +40,7 @@ class AnyOfPig(BaseModel):
|
||||
actual_instance: Optional[Union[BasquePig, DanishPig]] = None
|
||||
else:
|
||||
actual_instance: Any = None
|
||||
any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS]
|
||||
any_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -111,22 +112,20 @@ class AnyOfPig(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
return None
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
return self.actual_instance
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the actual instance"""
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.tag import Tag
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ArrayOfArrayOfModel(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class ArrayOfArrayOfModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfArrayOfModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class ArrayOfArrayOfModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list)
|
||||
@@ -81,7 +81,7 @@ class ArrayOfArrayOfModel(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfArrayOfModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -92,7 +92,7 @@ class ArrayOfArrayOfModel(BaseModel):
|
||||
_obj = cls.model_validate({
|
||||
"another_property": [
|
||||
[Tag.from_dict(_inner_item) for _inner_item in _item]
|
||||
for _item in obj.get("another_property")
|
||||
for _item in obj["another_property"]
|
||||
] if obj.get("another_property") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ArrayOfArrayOfNumberOnly(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ArrayOfArrayOfNumberOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfArrayOfNumberOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ArrayOfArrayOfNumberOnly(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfArrayOfNumberOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ArrayOfNumberOnly(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ArrayOfNumberOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfNumberOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ArrayOfNumberOnly(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ArrayOfNumberOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing_extensions import Annotated
|
||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ArrayTest(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class ArrayTest(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ArrayTest from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,10 +64,12 @@ class ArrayTest(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list)
|
||||
@@ -84,7 +84,7 @@ class ArrayTest(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ArrayTest from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -97,7 +97,7 @@ class ArrayTest(BaseModel):
|
||||
"array_array_of_integer": obj.get("array_array_of_integer"),
|
||||
"array_array_of_model": [
|
||||
[ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item]
|
||||
for _item in obj.get("array_array_of_model")
|
||||
for _item in obj["array_array_of_model"]
|
||||
] if obj.get("array_array_of_model") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class BasquePig(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class BasquePig(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of BasquePig from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class BasquePig(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of BasquePig from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Capitalization(BaseModel):
|
||||
"""
|
||||
@@ -53,7 +51,7 @@ class Capitalization(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Capitalization from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -67,16 +65,18 @@ class Capitalization(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Capitalization from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import StrictBool
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.animal import Animal
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Cat(Animal):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Cat(Animal):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Cat from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class Cat(Animal):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Cat from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Category(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Category(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Category from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class Category(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Category from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class CircularReferenceModel(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class CircularReferenceModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of CircularReferenceModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class CircularReferenceModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of nested
|
||||
@@ -75,7 +75,7 @@ class CircularReferenceModel(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of CircularReferenceModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class CircularReferenceModel(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"size": obj.get("size"),
|
||||
"nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None
|
||||
"nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ClassModel(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ClassModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ClassModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ClassModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ClassModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Client(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class Client(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Client from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class Client(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Client from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -35,7 +35,7 @@ class Color(BaseModel):
|
||||
# data type: str
|
||||
oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.")
|
||||
actual_instance: Optional[Union[List[int], str]] = None
|
||||
one_of_schemas: List[str] = Literal["List[int]", "str"]
|
||||
one_of_schemas: List[str] = Field(default=Literal["List[int]", "str"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -144,19 +144,17 @@ class Color(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, List[int], str]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return None
|
||||
|
||||
to_dict = getattr(self.actual_instance, "to_dict", None)
|
||||
if callable(to_dict):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
# primitive type
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List
|
||||
from petstore_api.models.creature_info import CreatureInfo
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Creature(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class Creature(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Creature from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,10 +62,12 @@ class Creature(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of info
|
||||
@@ -76,7 +76,7 @@ class Creature(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Creature from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class Creature(BaseModel):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None,
|
||||
"info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None,
|
||||
"type": obj.get("type")
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class CreatureInfo(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class CreatureInfo(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of CreatureInfo from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class CreatureInfo(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of CreatureInfo from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class DanishPig(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class DanishPig(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DanishPig from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class DanishPig(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of DanishPig from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class DeprecatedObject(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class DeprecatedObject(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DeprecatedObject from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class DeprecatedObject(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of DeprecatedObject from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.animal import Animal
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Dog(Animal):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Dog(Animal):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Dog from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class Dog(Animal):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Dog from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class DummyModel(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class DummyModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DummyModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class DummyModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of self_ref
|
||||
@@ -75,7 +75,7 @@ class DummyModel(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of DummyModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class DummyModel(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"category": obj.get("category"),
|
||||
"self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None
|
||||
"self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class EnumArrays(BaseModel):
|
||||
"""
|
||||
@@ -70,7 +68,7 @@ class EnumArrays(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of EnumArrays from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -84,16 +82,18 @@ class EnumArrays(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of EnumArrays from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -23,10 +23,8 @@ from petstore_api.models.outer_enum import OuterEnum
|
||||
from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue
|
||||
from petstore_api.models.outer_enum_integer import OuterEnumInteger
|
||||
from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class EnumTest(BaseModel):
|
||||
"""
|
||||
@@ -107,7 +105,7 @@ class EnumTest(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of EnumTest from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -121,10 +119,12 @@ class EnumTest(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# set to None if outer_enum (nullable) is None
|
||||
@@ -135,7 +135,7 @@ class EnumTest(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of EnumTest from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class File(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class File(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of File from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class File(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of File from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.file import File
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class FileSchemaTestClass(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class FileSchemaTestClass(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FileSchemaTestClass from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,10 +62,12 @@ class FileSchemaTestClass(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of file
|
||||
@@ -83,7 +83,7 @@ class FileSchemaTestClass(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of FileSchemaTestClass from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -92,8 +92,8 @@ class FileSchemaTestClass(BaseModel):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None,
|
||||
"files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None
|
||||
"file": File.from_dict(obj["file"]) if obj.get("file") is not None else None,
|
||||
"files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class FirstRef(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class FirstRef(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FirstRef from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class FirstRef(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of self_ref
|
||||
@@ -75,7 +75,7 @@ class FirstRef(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of FirstRef from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class FirstRef(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"category": obj.get("category"),
|
||||
"self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None
|
||||
"self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Foo(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class Foo(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Foo from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class Foo(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Foo from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.foo import Foo
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class FooGetDefaultResponse(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class FooGetDefaultResponse(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FooGetDefaultResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class FooGetDefaultResponse(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of string
|
||||
@@ -75,7 +75,7 @@ class FooGetDefaultResponse(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of FooGetDefaultResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -84,7 +84,7 @@ class FooGetDefaultResponse(BaseModel):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None
|
||||
"string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -22,10 +22,8 @@ from decimal import Decimal
|
||||
from pydantic import BaseModel, Field, StrictBytes, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing_extensions import Annotated
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class FormatTest(BaseModel):
|
||||
"""
|
||||
@@ -107,7 +105,7 @@ class FormatTest(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FormatTest from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -121,16 +119,18 @@ class FormatTest(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of FormatTest from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class HasOnlyReadOnly(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class HasOnlyReadOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of HasOnlyReadOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -65,18 +63,20 @@ class HasOnlyReadOnly(BaseModel):
|
||||
* OpenAPI `readOnly` fields are excluded.
|
||||
* OpenAPI `readOnly` fields are excluded.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
"bar",
|
||||
"foo",
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
"bar",
|
||||
"foo",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of HasOnlyReadOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class HealthCheckResult(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class HealthCheckResult(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of HealthCheckResult from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,10 +60,12 @@ class HealthCheckResult(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# set to None if nullable_message (nullable) is None
|
||||
@@ -76,7 +76,7 @@ class HealthCheckResult(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of HealthCheckResult from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class InnerDictWithProperty(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class InnerDictWithProperty(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InnerDictWithProperty from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class InnerDictWithProperty(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of InnerDictWithProperty from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -33,7 +33,7 @@ class IntOrString(BaseModel):
|
||||
# data type: str
|
||||
oneof_schema_2_validator: Optional[StrictStr] = None
|
||||
actual_instance: Optional[Union[int, str]] = None
|
||||
one_of_schemas: List[str] = Literal["int", "str"]
|
||||
one_of_schemas: List[str] = Field(default=Literal["int", "str"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -121,19 +121,17 @@ class IntOrString(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, int, str]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return None
|
||||
|
||||
to_dict = getattr(self.actual_instance, "to_dict", None)
|
||||
if callable(to_dict):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
# primitive type
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ListClass(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ListClass(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ListClass from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ListClass(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ListClass from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.tag import Tag
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class MapOfArrayOfModel(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class MapOfArrayOfModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of MapOfArrayOfModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class MapOfArrayOfModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array)
|
||||
@@ -81,7 +81,7 @@ class MapOfArrayOfModel(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of MapOfArrayOfModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -96,7 +96,7 @@ class MapOfArrayOfModel(BaseModel):
|
||||
if _v is not None
|
||||
else None
|
||||
)
|
||||
for _k, _v in obj.get("shopIdToOrgOnlineLipMap").items()
|
||||
for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items()
|
||||
)
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictBool, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class MapTest(BaseModel):
|
||||
"""
|
||||
@@ -61,7 +59,7 @@ class MapTest(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of MapTest from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -75,16 +73,18 @@ class MapTest(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of MapTest from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ from datetime import datetime
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.animal import Animal
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,10 +64,12 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in map (dict)
|
||||
@@ -82,7 +82,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -95,7 +95,7 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel):
|
||||
"dateTime": obj.get("dateTime"),
|
||||
"map": dict(
|
||||
(_k, Animal.from_dict(_v))
|
||||
for _k, _v in obj.get("map").items()
|
||||
for _k, _v in obj["map"].items()
|
||||
)
|
||||
if obj.get("map") is not None
|
||||
else None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Model200Response(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Model200Response(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Model200Response from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class Model200Response(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Model200Response from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,14 +19,12 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ApiResponse(BaseModel):
|
||||
class ModelApiResponse(BaseModel):
|
||||
"""
|
||||
ApiResponse
|
||||
ModelApiResponse
|
||||
""" # noqa: E501
|
||||
code: Optional[StrictInt] = None
|
||||
type: Optional[StrictStr] = None
|
||||
@@ -50,8 +48,8 @@ class ApiResponse(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
"""Create an instance of ApiResponse from a JSON string"""
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ModelApiResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
@@ -64,17 +62,19 @@ class ApiResponse(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
"""Create an instance of ApiResponse from a dict"""
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ModelApiResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ModelReturn(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ModelReturn(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ModelReturn from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ModelReturn(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ModelReturn from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Name(BaseModel):
|
||||
"""
|
||||
@@ -51,7 +49,7 @@ class Name(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Name from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -67,18 +65,20 @@ class Name(BaseModel):
|
||||
* OpenAPI `readOnly` fields are excluded.
|
||||
* OpenAPI `readOnly` fields are excluded.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
"snake_case",
|
||||
"var_123_number",
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
"snake_case",
|
||||
"var_123_number",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Name from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, StrictBool, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class NullableClass(BaseModel):
|
||||
"""
|
||||
@@ -62,7 +60,7 @@ class NullableClass(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of NullableClass from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -77,11 +75,13 @@ class NullableClass(BaseModel):
|
||||
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={
|
||||
"additional_properties",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
@@ -147,7 +147,7 @@ class NullableClass(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of NullableClass from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field, StrictInt, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing_extensions import Annotated
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class NullableProperty(BaseModel):
|
||||
"""
|
||||
@@ -60,7 +58,7 @@ class NullableProperty(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of NullableProperty from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -74,10 +72,12 @@ class NullableProperty(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# set to None if name (nullable) is None
|
||||
@@ -88,7 +88,7 @@ class NullableProperty(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of NullableProperty from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class NumberOnly(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class NumberOnly(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of NumberOnly from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class NumberOnly(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of NumberOnly from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictBool
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ObjectToTestAdditionalProperties(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class ObjectToTestAdditionalProperties(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ObjectToTestAdditionalProperties from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class ObjectToTestAdditionalProperties(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ObjectToTestAdditionalProperties from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.deprecated_object import DeprecatedObject
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ObjectWithDeprecatedFields(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class ObjectWithDeprecatedFields(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ObjectWithDeprecatedFields from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,10 +64,12 @@ class ObjectWithDeprecatedFields(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of deprecated_ref
|
||||
@@ -78,7 +78,7 @@ class ObjectWithDeprecatedFields(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ObjectWithDeprecatedFields from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -89,7 +89,7 @@ class ObjectWithDeprecatedFields(BaseModel):
|
||||
_obj = cls.model_validate({
|
||||
"uuid": obj.get("uuid"),
|
||||
"id": obj.get("id"),
|
||||
"deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None,
|
||||
"deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None,
|
||||
"bars": obj.get("bars")
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -34,7 +34,7 @@ class OneOfEnumString(BaseModel):
|
||||
# data type: EnumString2
|
||||
oneof_schema_2_validator: Optional[EnumString2] = None
|
||||
actual_instance: Optional[Union[EnumString1, EnumString2]] = None
|
||||
one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"]
|
||||
one_of_schemas: List[str] = Field(default=Literal["EnumString1", "EnumString2"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -114,19 +114,17 @@ class OneOfEnumString(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, EnumString1, EnumString2]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return None
|
||||
|
||||
to_dict = getattr(self.actual_instance, "to_dict", None)
|
||||
if callable(to_dict):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
# primitive type
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Order(BaseModel):
|
||||
"""
|
||||
@@ -64,7 +62,7 @@ class Order(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Order from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -78,16 +76,18 @@ class Order(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Order from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictBool, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class OuterComposite(BaseModel):
|
||||
"""
|
||||
@@ -50,7 +48,7 @@ class OuterComposite(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of OuterComposite from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class OuterComposite(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of OuterComposite from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ from pydantic import BaseModel
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.outer_enum import OuterEnum
|
||||
from petstore_api.models.outer_enum_integer import OuterEnumInteger
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class OuterObjectWithEnumProperty(BaseModel):
|
||||
"""
|
||||
@@ -51,7 +49,7 @@ class OuterObjectWithEnumProperty(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of OuterObjectWithEnumProperty from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -65,10 +63,12 @@ class OuterObjectWithEnumProperty(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# set to None if str_value (nullable) is None
|
||||
@@ -79,7 +79,7 @@ class OuterObjectWithEnumProperty(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of OuterObjectWithEnumProperty from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Parent(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Parent(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Parent from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class Parent(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict)
|
||||
@@ -79,7 +79,7 @@ class Parent(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Parent from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -90,7 +90,7 @@ class Parent(BaseModel):
|
||||
_obj = cls.model_validate({
|
||||
"optionalDict": dict(
|
||||
(_k, InnerDictWithProperty.from_dict(_v))
|
||||
for _k, _v in obj.get("optionalDict").items()
|
||||
for _k, _v in obj["optionalDict"].items()
|
||||
)
|
||||
if obj.get("optionalDict") is not None
|
||||
else None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ParentWithOptionalDict(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class ParentWithOptionalDict(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ParentWithOptionalDict from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class ParentWithOptionalDict(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict)
|
||||
@@ -79,7 +79,7 @@ class ParentWithOptionalDict(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ParentWithOptionalDict from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -90,7 +90,7 @@ class ParentWithOptionalDict(BaseModel):
|
||||
_obj = cls.model_validate({
|
||||
"optionalDict": dict(
|
||||
(_k, InnerDictWithProperty.from_dict(_v))
|
||||
for _k, _v in obj.get("optionalDict").items()
|
||||
for _k, _v in obj["optionalDict"].items()
|
||||
)
|
||||
if obj.get("optionalDict") is not None
|
||||
else None
|
||||
|
||||
@@ -22,10 +22,8 @@ from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing_extensions import Annotated
|
||||
from petstore_api.models.category import Category
|
||||
from petstore_api.models.tag import Tag
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Pet(BaseModel):
|
||||
"""
|
||||
@@ -66,7 +64,7 @@ class Pet(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Pet from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -80,10 +78,12 @@ class Pet(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of category
|
||||
@@ -99,7 +99,7 @@ class Pet(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Pet from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -109,10 +109,10 @@ class Pet(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None,
|
||||
"category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None,
|
||||
"name": obj.get("name"),
|
||||
"photoUrls": obj.get("photoUrls"),
|
||||
"tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None,
|
||||
"tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None,
|
||||
"status": obj.get("status")
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -34,7 +34,7 @@ class Pig(BaseModel):
|
||||
# data type: DanishPig
|
||||
oneof_schema_2_validator: Optional[DanishPig] = None
|
||||
actual_instance: Optional[Union[BasquePig, DanishPig]] = None
|
||||
one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"]
|
||||
one_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"])
|
||||
|
||||
model_config = {
|
||||
"validate_assignment": True,
|
||||
@@ -117,19 +117,17 @@ class Pig(BaseModel):
|
||||
if self.actual_instance is None:
|
||||
return "null"
|
||||
|
||||
to_json = getattr(self.actual_instance, "to_json", None)
|
||||
if callable(to_json):
|
||||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
||||
return self.actual_instance.to_json()
|
||||
else:
|
||||
return json.dumps(self.actual_instance)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]:
|
||||
"""Returns the dict representation of the actual instance"""
|
||||
if self.actual_instance is None:
|
||||
return None
|
||||
|
||||
to_dict = getattr(self.actual_instance, "to_dict", None)
|
||||
if callable(to_dict):
|
||||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
||||
return self.actual_instance.to_dict()
|
||||
else:
|
||||
# primitive type
|
||||
|
||||
@@ -19,18 +19,16 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class PropertyNameCollision(BaseModel):
|
||||
"""
|
||||
PropertyNameCollision
|
||||
""" # noqa: E501
|
||||
type: Optional[StrictStr] = Field(default=None, alias="_type")
|
||||
underscore_type: Optional[StrictStr] = Field(default=None, alias="_type")
|
||||
type: Optional[StrictStr] = None
|
||||
type_: Optional[StrictStr] = None
|
||||
type_with_underscore: Optional[StrictStr] = Field(default=None, alias="type_")
|
||||
__properties: ClassVar[List[str]] = ["_type", "type", "type_"]
|
||||
|
||||
model_config = {
|
||||
@@ -50,7 +48,7 @@ class PropertyNameCollision(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of PropertyNameCollision from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,16 +62,18 @@ class PropertyNameCollision(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of PropertyNameCollision from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class ReadOnlyFirst(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class ReadOnlyFirst(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ReadOnlyFirst from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,17 +62,19 @@ class ReadOnlyFirst(BaseModel):
|
||||
are ignored.
|
||||
* OpenAPI `readOnly` fields are excluded.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
"bar",
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude={
|
||||
"bar",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of ReadOnlyFirst from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class SecondRef(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class SecondRef(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SecondRef from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class SecondRef(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of circular_ref
|
||||
@@ -75,7 +75,7 @@ class SecondRef(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of SecondRef from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class SecondRef(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"category": obj.get("category"),
|
||||
"circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None
|
||||
"circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class SelfReferenceModel(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class SelfReferenceModel(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SelfReferenceModel from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class SelfReferenceModel(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of nested
|
||||
@@ -75,7 +75,7 @@ class SelfReferenceModel(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of SelfReferenceModel from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ class SelfReferenceModel(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"size": obj.get("size"),
|
||||
"nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None
|
||||
"nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class SpecialModelName(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class SpecialModelName(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SpecialModelName from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class SpecialModelName(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of SpecialModelName from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.category import Category
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class SpecialName(BaseModel):
|
||||
"""
|
||||
@@ -61,7 +59,7 @@ class SpecialName(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SpecialName from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -75,10 +73,12 @@ class SpecialName(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of var_async
|
||||
@@ -87,7 +87,7 @@ class SpecialName(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of SpecialName from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -97,7 +97,7 @@ class SpecialName(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"property": obj.get("property"),
|
||||
"async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None,
|
||||
"async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None,
|
||||
"schema": obj.get("schema")
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Tag(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class Tag(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Tag from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,16 +61,18 @@ class Tag(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Tag from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestErrorResponsesWithModel400Response(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class TestErrorResponsesWithModel400Response(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestErrorResponsesWithModel400Response from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class TestErrorResponsesWithModel400Response(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of TestErrorResponsesWithModel400Response from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestErrorResponsesWithModel404Response(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class TestErrorResponsesWithModel404Response(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestErrorResponsesWithModel404Response from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class TestErrorResponsesWithModel404Response(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of TestErrorResponsesWithModel404Response from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -64,11 +62,13 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
|
||||
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={
|
||||
"additional_properties",
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# puts key-value pairs in additional_properties in the top level
|
||||
@@ -79,7 +79,7 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class Tiger(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class Tiger(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Tiger from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class Tiger(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of Tiger from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -20,10 +20,8 @@ import json
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.creature_info import CreatureInfo
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
"""
|
||||
@@ -49,7 +47,7 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -63,10 +61,12 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array)
|
||||
@@ -81,7 +81,7 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -96,7 +96,7 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel):
|
||||
if _v is not None
|
||||
else None
|
||||
)
|
||||
for _k, _v in obj.get("dictProperty").items()
|
||||
for _k, _v in obj.get("dictProperty", {}).items()
|
||||
)
|
||||
})
|
||||
return _obj
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class UnnamedDictWithAdditionalStringListProperties(BaseModel):
|
||||
"""
|
||||
@@ -48,7 +46,7 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -62,16 +60,18 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -19,10 +19,8 @@ import json
|
||||
|
||||
from pydantic import BaseModel, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class User(BaseModel):
|
||||
"""
|
||||
@@ -55,7 +53,7 @@ class User(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of User from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -69,16 +67,18 @@ class User(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of User from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
@@ -21,10 +21,8 @@ from pydantic import BaseModel, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from petstore_api.models.one_of_enum_string import OneOfEnumString
|
||||
from petstore_api.models.pig import Pig
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
|
||||
class WithNestedOneOf(BaseModel):
|
||||
"""
|
||||
@@ -52,7 +50,7 @@ class WithNestedOneOf(BaseModel):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Self:
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of WithNestedOneOf from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
@@ -66,10 +64,12 @@ class WithNestedOneOf(BaseModel):
|
||||
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={
|
||||
},
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of nested_pig
|
||||
@@ -81,7 +81,7 @@ class WithNestedOneOf(BaseModel):
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Dict) -> Self:
|
||||
def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]:
|
||||
"""Create an instance of WithNestedOneOf from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
@@ -91,8 +91,8 @@ class WithNestedOneOf(BaseModel):
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"size": obj.get("size"),
|
||||
"nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None,
|
||||
"nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None
|
||||
"nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None,
|
||||
"nested_oneof_enum_string": OneOfEnumString.from_dict(obj["nested_oneof_enum_string"]) if obj.get("nested_oneof_enum_string") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import io
|
||||
import json
|
||||
import re
|
||||
import ssl
|
||||
from typing import Optional
|
||||
|
||||
import aiohttp
|
||||
import aiohttp_retry
|
||||
@@ -82,6 +83,7 @@ class RESTClientObject:
|
||||
)
|
||||
|
||||
retries = configuration.retries
|
||||
self.retry_client: Optional[aiohttp_retry.RetryClient]
|
||||
if retries is not None:
|
||||
self.retry_client = aiohttp_retry.RetryClient(
|
||||
client_session=self.pool_manager,
|
||||
|
||||
@@ -25,6 +25,9 @@ typing-extensions = ">=4.7.1"
|
||||
pytest = ">=7.2.1"
|
||||
tox = ">=3.9.0"
|
||||
flake8 = ">=4.0.0"
|
||||
types-python-dateutil = ">=2.8.19.14"
|
||||
mypy = "1.4.1"
|
||||
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
@@ -32,3 +35,10 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.pylint.'MESSAGES CONTROL']
|
||||
extension-pkg-whitelist = "pydantic"
|
||||
|
||||
[tool.mypy]
|
||||
files = [
|
||||
"petstore_api",
|
||||
#"test", # auto-generated tests
|
||||
"tests", # hand-written tests
|
||||
]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
pytest~=7.1.3
|
||||
pytest-cov>=2.8.1
|
||||
pytest-randomly>=3.12.0
|
||||
mypy>=1.4.1
|
||||
types-python-dateutil>=2.8.19
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# 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: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.models.api_response import ApiResponse # noqa: E501
|
||||
from petstore_api.rest import ApiException
|
||||
|
||||
class TestApiResponse(unittest.TestCase):
|
||||
"""ApiResponse unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional):
|
||||
"""Test ApiResponse
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# model = petstore_api.models.api_response.ApiResponse() # noqa: E501
|
||||
if include_optional :
|
||||
return ApiResponse(
|
||||
code = 56,
|
||||
type = '',
|
||||
message = ''
|
||||
)
|
||||
else :
|
||||
return ApiResponse(
|
||||
)
|
||||
|
||||
def testApiResponse(self):
|
||||
"""Test ApiResponse"""
|
||||
# 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,54 @@
|
||||
# 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.model_api_response import ModelApiResponse
|
||||
|
||||
class TestModelApiResponse(unittest.TestCase):
|
||||
"""ModelApiResponse unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> ModelApiResponse:
|
||||
"""Test ModelApiResponse
|
||||
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 `ModelApiResponse`
|
||||
"""
|
||||
model = ModelApiResponse()
|
||||
if include_optional:
|
||||
return ModelApiResponse(
|
||||
code = 56,
|
||||
type = '',
|
||||
message = ''
|
||||
)
|
||||
else:
|
||||
return ModelApiResponse(
|
||||
)
|
||||
"""
|
||||
|
||||
def testModelApiResponse(self):
|
||||
"""Test ModelApiResponse"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user