forked from loafle/openapi-generator-original
[PYTHON] Fix for failing to lookup discriminator value using AllOf and discriminator (#18498)
* fix issue 18495 * add tests and update samples * update samples
This commit is contained in:
committed by
GitHub
parent
bd02e65f88
commit
81fab15a33
@@ -237,7 +237,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
|||||||
# look up the object type based on discriminator mapping
|
# look up the object type based on discriminator mapping
|
||||||
object_type = cls.get_discriminator_value(obj)
|
object_type = cls.get_discriminator_value(obj)
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
if object_type == '{{{mappingName}}}':
|
if object_type == '{{{modelName}}}':
|
||||||
return import_module("{{packageName}}.models.{{model.classVarName}}").{{modelName}}.from_dict(obj)
|
return import_module("{{packageName}}.models.{{model.classVarName}}").{{modelName}}.from_dict(obj)
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
raise ValueError("{{{classname}}} failed to lookup discriminator value from " +
|
raise ValueError("{{{classname}}} failed to lookup discriminator value from " +
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
|
|||||||
# look up the object type based on discriminator mapping
|
# look up the object type based on discriminator mapping
|
||||||
object_type = cls.get_discriminator_value(obj)
|
object_type = cls.get_discriminator_value(obj)
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
if object_type == '{{{mappingName}}}':
|
if object_type == '{{{modelName}}}':
|
||||||
return import_module("{{packageName}}.models.{{model.classVarName}}").{{modelName}}.from_dict(obj)
|
return import_module("{{packageName}}.models.{{model.classVarName}}").{{modelName}}.from_dict(obj)
|
||||||
{{/mappedModels}}
|
{{/mappedModels}}
|
||||||
|
|
||||||
|
|||||||
@@ -2741,3 +2741,26 @@ components:
|
|||||||
_name:
|
_name:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
Info:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/components/schemas/BaseDiscriminator'
|
||||||
|
- properties:
|
||||||
|
val:
|
||||||
|
$ref: '#/components/schemas/BaseDiscriminator'
|
||||||
|
type: object
|
||||||
|
BaseDiscriminator:
|
||||||
|
discriminator:
|
||||||
|
mapping:
|
||||||
|
string: '#/components/schemas/PrimitiveString'
|
||||||
|
propertyName: _typeName
|
||||||
|
properties:
|
||||||
|
_typeName:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
PrimitiveString:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/components/schemas/BaseDiscriminator'
|
||||||
|
- properties:
|
||||||
|
_value:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
@@ -17,6 +17,7 @@ docs/ArrayOfArrayOfModel.md
|
|||||||
docs/ArrayOfArrayOfNumberOnly.md
|
docs/ArrayOfArrayOfNumberOnly.md
|
||||||
docs/ArrayOfNumberOnly.md
|
docs/ArrayOfNumberOnly.md
|
||||||
docs/ArrayTest.md
|
docs/ArrayTest.md
|
||||||
|
docs/BaseDiscriminator.md
|
||||||
docs/BasquePig.md
|
docs/BasquePig.md
|
||||||
docs/Bathing.md
|
docs/Bathing.md
|
||||||
docs/Capitalization.md
|
docs/Capitalization.md
|
||||||
@@ -53,6 +54,7 @@ docs/FormatTest.md
|
|||||||
docs/HasOnlyReadOnly.md
|
docs/HasOnlyReadOnly.md
|
||||||
docs/HealthCheckResult.md
|
docs/HealthCheckResult.md
|
||||||
docs/ImportTestDatetimeApi.md
|
docs/ImportTestDatetimeApi.md
|
||||||
|
docs/Info.md
|
||||||
docs/InnerDictWithProperty.md
|
docs/InnerDictWithProperty.md
|
||||||
docs/InputAllOf.md
|
docs/InputAllOf.md
|
||||||
docs/IntOrString.md
|
docs/IntOrString.md
|
||||||
@@ -84,6 +86,7 @@ docs/Pet.md
|
|||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
docs/Pig.md
|
docs/Pig.md
|
||||||
docs/PoopCleaning.md
|
docs/PoopCleaning.md
|
||||||
|
docs/PrimitiveString.md
|
||||||
docs/PropertyMap.md
|
docs/PropertyMap.md
|
||||||
docs/PropertyNameCollision.md
|
docs/PropertyNameCollision.md
|
||||||
docs/ReadOnlyFirst.md
|
docs/ReadOnlyFirst.md
|
||||||
@@ -137,6 +140,7 @@ petstore_api/models/array_of_array_of_model.py
|
|||||||
petstore_api/models/array_of_array_of_number_only.py
|
petstore_api/models/array_of_array_of_number_only.py
|
||||||
petstore_api/models/array_of_number_only.py
|
petstore_api/models/array_of_number_only.py
|
||||||
petstore_api/models/array_test.py
|
petstore_api/models/array_test.py
|
||||||
|
petstore_api/models/base_discriminator.py
|
||||||
petstore_api/models/basque_pig.py
|
petstore_api/models/basque_pig.py
|
||||||
petstore_api/models/bathing.py
|
petstore_api/models/bathing.py
|
||||||
petstore_api/models/capitalization.py
|
petstore_api/models/capitalization.py
|
||||||
@@ -169,6 +173,7 @@ petstore_api/models/foo_get_default_response.py
|
|||||||
petstore_api/models/format_test.py
|
petstore_api/models/format_test.py
|
||||||
petstore_api/models/has_only_read_only.py
|
petstore_api/models/has_only_read_only.py
|
||||||
petstore_api/models/health_check_result.py
|
petstore_api/models/health_check_result.py
|
||||||
|
petstore_api/models/info.py
|
||||||
petstore_api/models/inner_dict_with_property.py
|
petstore_api/models/inner_dict_with_property.py
|
||||||
petstore_api/models/input_all_of.py
|
petstore_api/models/input_all_of.py
|
||||||
petstore_api/models/int_or_string.py
|
petstore_api/models/int_or_string.py
|
||||||
@@ -199,6 +204,7 @@ petstore_api/models/parent_with_optional_dict.py
|
|||||||
petstore_api/models/pet.py
|
petstore_api/models/pet.py
|
||||||
petstore_api/models/pig.py
|
petstore_api/models/pig.py
|
||||||
petstore_api/models/poop_cleaning.py
|
petstore_api/models/poop_cleaning.py
|
||||||
|
petstore_api/models/primitive_string.py
|
||||||
petstore_api/models/property_map.py
|
petstore_api/models/property_map.py
|
||||||
petstore_api/models/property_name_collision.py
|
petstore_api/models/property_name_collision.py
|
||||||
petstore_api/models/read_only_first.py
|
petstore_api/models/read_only_first.py
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
- [ArrayTest](docs/ArrayTest.md)
|
- [ArrayTest](docs/ArrayTest.md)
|
||||||
|
- [BaseDiscriminator](docs/BaseDiscriminator.md)
|
||||||
- [BasquePig](docs/BasquePig.md)
|
- [BasquePig](docs/BasquePig.md)
|
||||||
- [Bathing](docs/Bathing.md)
|
- [Bathing](docs/Bathing.md)
|
||||||
- [Capitalization](docs/Capitalization.md)
|
- [Capitalization](docs/Capitalization.md)
|
||||||
@@ -195,6 +196,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [FormatTest](docs/FormatTest.md)
|
- [FormatTest](docs/FormatTest.md)
|
||||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||||
|
- [Info](docs/Info.md)
|
||||||
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
||||||
- [InputAllOf](docs/InputAllOf.md)
|
- [InputAllOf](docs/InputAllOf.md)
|
||||||
- [IntOrString](docs/IntOrString.md)
|
- [IntOrString](docs/IntOrString.md)
|
||||||
@@ -225,6 +227,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [Pig](docs/Pig.md)
|
- [Pig](docs/Pig.md)
|
||||||
- [PoopCleaning](docs/PoopCleaning.md)
|
- [PoopCleaning](docs/PoopCleaning.md)
|
||||||
|
- [PrimitiveString](docs/PrimitiveString.md)
|
||||||
- [PropertyMap](docs/PropertyMap.md)
|
- [PropertyMap](docs/PropertyMap.md)
|
||||||
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
||||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# BaseDiscriminator
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**type_name** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of BaseDiscriminator from a JSON string
|
||||||
|
base_discriminator_instance = BaseDiscriminator.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(BaseDiscriminator.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
base_discriminator_dict = base_discriminator_instance.to_dict()
|
||||||
|
# create an instance of BaseDiscriminator from a dict
|
||||||
|
base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_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)
|
||||||
|
|
||||||
|
|
||||||
29
samples/openapi3/client/petstore/python-aiohttp/docs/Info.md
Normal file
29
samples/openapi3/client/petstore/python-aiohttp/docs/Info.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Info
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**val** | [**BaseDiscriminator**](BaseDiscriminator.md) | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of Info from a JSON string
|
||||||
|
info_instance = Info.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(Info.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
info_dict = info_instance.to_dict()
|
||||||
|
# create an instance of Info from a dict
|
||||||
|
info_from_dict = Info.from_dict(info_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# PrimitiveString
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**value** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of PrimitiveString from a JSON string
|
||||||
|
primitive_string_instance = PrimitiveString.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(PrimitiveString.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
primitive_string_dict = primitive_string_instance.to_dict()
|
||||||
|
# create an instance of PrimitiveString from a dict
|
||||||
|
primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_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)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -84,6 +85,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -114,6 +116,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -59,6 +60,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -89,6 +91,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from importlib import import_module
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class BaseDiscriminator(BaseModel):
|
||||||
|
"""
|
||||||
|
BaseDiscriminator
|
||||||
|
""" # noqa: E501
|
||||||
|
type_name: Optional[StrictStr] = Field(default=None, alias="_typeName")
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# JSON field name that stores the object type
|
||||||
|
__discriminator_property_name: ClassVar[str] = '_typeName'
|
||||||
|
|
||||||
|
# discriminator mappings
|
||||||
|
__discriminator_value_class_map: ClassVar[Dict[str, str]] = {
|
||||||
|
'string': 'PrimitiveString','Info': 'Info'
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]:
|
||||||
|
"""Returns the discriminator value (object type) of the data"""
|
||||||
|
discriminator_value = obj[cls.__discriminator_property_name]
|
||||||
|
if discriminator_value:
|
||||||
|
return cls.__discriminator_value_class_map.get(discriminator_value)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]:
|
||||||
|
"""Create an instance of BaseDiscriminator from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]:
|
||||||
|
"""Create an instance of BaseDiscriminator from a dict"""
|
||||||
|
# look up the object type based on discriminator mapping
|
||||||
|
object_type = cls.get_discriminator_value(obj)
|
||||||
|
if object_type == 'PrimitiveString':
|
||||||
|
return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj)
|
||||||
|
if object_type == 'Info':
|
||||||
|
return import_module("petstore_api.models.info").Info.from_dict(obj)
|
||||||
|
|
||||||
|
raise ValueError("BaseDiscriminator failed to lookup discriminator value from " +
|
||||||
|
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
|
||||||
|
", mapping: " + json.dumps(cls.__discriminator_value_class_map))
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from pydantic import ConfigDict
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
class Info(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
Info
|
||||||
|
""" # noqa: E501
|
||||||
|
val: Optional[BaseDiscriminator] = None
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName", "val"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
|
"""Create an instance of Info from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of val
|
||||||
|
if self.val:
|
||||||
|
_dict['val'] = self.val.to_dict()
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||||
|
"""Create an instance of Info from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return cls.model_validate(obj)
|
||||||
|
|
||||||
|
_obj = cls.model_validate({
|
||||||
|
"_typeName": obj.get("_typeName"),
|
||||||
|
"val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None
|
||||||
|
})
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from pydantic import ConfigDict, Field, StrictStr
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
class PrimitiveString(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
PrimitiveString
|
||||||
|
""" # noqa: E501
|
||||||
|
value: Optional[StrictStr] = Field(default=None, alias="_value")
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName", "_value"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
|
"""Create an instance of PrimitiveString from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||||
|
"""Create an instance of PrimitiveString from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return cls.model_validate(obj)
|
||||||
|
|
||||||
|
_obj = cls.model_validate({
|
||||||
|
"_typeName": obj.get("_typeName"),
|
||||||
|
"_value": obj.get("_value")
|
||||||
|
})
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class TestBaseDiscriminator(unittest.TestCase):
|
||||||
|
"""BaseDiscriminator unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> BaseDiscriminator:
|
||||||
|
"""Test BaseDiscriminator
|
||||||
|
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 `BaseDiscriminator`
|
||||||
|
"""
|
||||||
|
model = BaseDiscriminator()
|
||||||
|
if include_optional:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
type_name = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testBaseDiscriminator(self):
|
||||||
|
"""Test BaseDiscriminator"""
|
||||||
|
# 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,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class TestInfo(unittest.TestCase):
|
||||||
|
"""Info unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> Info:
|
||||||
|
"""Test Info
|
||||||
|
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 `Info`
|
||||||
|
"""
|
||||||
|
model = Info()
|
||||||
|
if include_optional:
|
||||||
|
return Info(
|
||||||
|
val = petstore_api.models.base_discriminator.BaseDiscriminator()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Info(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testInfo(self):
|
||||||
|
"""Test Info"""
|
||||||
|
# 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,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
class TestPrimitiveString(unittest.TestCase):
|
||||||
|
"""PrimitiveString unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> PrimitiveString:
|
||||||
|
"""Test PrimitiveString
|
||||||
|
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 `PrimitiveString`
|
||||||
|
"""
|
||||||
|
model = PrimitiveString()
|
||||||
|
if include_optional:
|
||||||
|
return PrimitiveString(
|
||||||
|
value = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return PrimitiveString(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testPrimitiveString(self):
|
||||||
|
"""Test PrimitiveString"""
|
||||||
|
# inst_req_only = self.make_instance(include_optional=False)
|
||||||
|
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -18,6 +18,7 @@ docs/ArrayOfArrayOfModel.md
|
|||||||
docs/ArrayOfArrayOfNumberOnly.md
|
docs/ArrayOfArrayOfNumberOnly.md
|
||||||
docs/ArrayOfNumberOnly.md
|
docs/ArrayOfNumberOnly.md
|
||||||
docs/ArrayTest.md
|
docs/ArrayTest.md
|
||||||
|
docs/BaseDiscriminator.md
|
||||||
docs/BasquePig.md
|
docs/BasquePig.md
|
||||||
docs/Bathing.md
|
docs/Bathing.md
|
||||||
docs/Capitalization.md
|
docs/Capitalization.md
|
||||||
@@ -55,6 +56,7 @@ docs/FormatTest.md
|
|||||||
docs/HasOnlyReadOnly.md
|
docs/HasOnlyReadOnly.md
|
||||||
docs/HealthCheckResult.md
|
docs/HealthCheckResult.md
|
||||||
docs/ImportTestDatetimeApi.md
|
docs/ImportTestDatetimeApi.md
|
||||||
|
docs/Info.md
|
||||||
docs/InnerDictWithProperty.md
|
docs/InnerDictWithProperty.md
|
||||||
docs/InputAllOf.md
|
docs/InputAllOf.md
|
||||||
docs/IntOrString.md
|
docs/IntOrString.md
|
||||||
@@ -84,6 +86,7 @@ docs/Pet.md
|
|||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
docs/Pig.md
|
docs/Pig.md
|
||||||
docs/PoopCleaning.md
|
docs/PoopCleaning.md
|
||||||
|
docs/PrimitiveString.md
|
||||||
docs/PropertyMap.md
|
docs/PropertyMap.md
|
||||||
docs/PropertyNameCollision.md
|
docs/PropertyNameCollision.md
|
||||||
docs/ReadOnlyFirst.md
|
docs/ReadOnlyFirst.md
|
||||||
@@ -138,6 +141,7 @@ petstore_api/models/array_of_array_of_model.py
|
|||||||
petstore_api/models/array_of_array_of_number_only.py
|
petstore_api/models/array_of_array_of_number_only.py
|
||||||
petstore_api/models/array_of_number_only.py
|
petstore_api/models/array_of_number_only.py
|
||||||
petstore_api/models/array_test.py
|
petstore_api/models/array_test.py
|
||||||
|
petstore_api/models/base_discriminator.py
|
||||||
petstore_api/models/basque_pig.py
|
petstore_api/models/basque_pig.py
|
||||||
petstore_api/models/bathing.py
|
petstore_api/models/bathing.py
|
||||||
petstore_api/models/capitalization.py
|
petstore_api/models/capitalization.py
|
||||||
@@ -171,6 +175,7 @@ petstore_api/models/foo_get_default_response.py
|
|||||||
petstore_api/models/format_test.py
|
petstore_api/models/format_test.py
|
||||||
petstore_api/models/has_only_read_only.py
|
petstore_api/models/has_only_read_only.py
|
||||||
petstore_api/models/health_check_result.py
|
petstore_api/models/health_check_result.py
|
||||||
|
petstore_api/models/info.py
|
||||||
petstore_api/models/inner_dict_with_property.py
|
petstore_api/models/inner_dict_with_property.py
|
||||||
petstore_api/models/input_all_of.py
|
petstore_api/models/input_all_of.py
|
||||||
petstore_api/models/int_or_string.py
|
petstore_api/models/int_or_string.py
|
||||||
@@ -199,6 +204,7 @@ petstore_api/models/parent_with_optional_dict.py
|
|||||||
petstore_api/models/pet.py
|
petstore_api/models/pet.py
|
||||||
petstore_api/models/pig.py
|
petstore_api/models/pig.py
|
||||||
petstore_api/models/poop_cleaning.py
|
petstore_api/models/poop_cleaning.py
|
||||||
|
petstore_api/models/primitive_string.py
|
||||||
petstore_api/models/property_map.py
|
petstore_api/models/property_map.py
|
||||||
petstore_api/models/property_name_collision.py
|
petstore_api/models/property_name_collision.py
|
||||||
petstore_api/models/read_only_first.py
|
petstore_api/models/read_only_first.py
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
- [ArrayTest](docs/ArrayTest.md)
|
- [ArrayTest](docs/ArrayTest.md)
|
||||||
|
- [BaseDiscriminator](docs/BaseDiscriminator.md)
|
||||||
- [BasquePig](docs/BasquePig.md)
|
- [BasquePig](docs/BasquePig.md)
|
||||||
- [Bathing](docs/Bathing.md)
|
- [Bathing](docs/Bathing.md)
|
||||||
- [Capitalization](docs/Capitalization.md)
|
- [Capitalization](docs/Capitalization.md)
|
||||||
@@ -198,6 +199,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [FormatTest](docs/FormatTest.md)
|
- [FormatTest](docs/FormatTest.md)
|
||||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||||
|
- [Info](docs/Info.md)
|
||||||
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
||||||
- [InputAllOf](docs/InputAllOf.md)
|
- [InputAllOf](docs/InputAllOf.md)
|
||||||
- [IntOrString](docs/IntOrString.md)
|
- [IntOrString](docs/IntOrString.md)
|
||||||
@@ -226,6 +228,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [Pig](docs/Pig.md)
|
- [Pig](docs/Pig.md)
|
||||||
- [PoopCleaning](docs/PoopCleaning.md)
|
- [PoopCleaning](docs/PoopCleaning.md)
|
||||||
|
- [PrimitiveString](docs/PrimitiveString.md)
|
||||||
- [PropertyMap](docs/PropertyMap.md)
|
- [PropertyMap](docs/PropertyMap.md)
|
||||||
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
||||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# BaseDiscriminator
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**type_name** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of BaseDiscriminator from a JSON string
|
||||||
|
base_discriminator_instance = BaseDiscriminator.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print BaseDiscriminator.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
base_discriminator_dict = base_discriminator_instance.to_dict()
|
||||||
|
# create an instance of BaseDiscriminator from a dict
|
||||||
|
base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Info
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**val** | [**BaseDiscriminator**](BaseDiscriminator.md) | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of Info from a JSON string
|
||||||
|
info_instance = Info.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print Info.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
info_dict = info_instance.to_dict()
|
||||||
|
# create an instance of Info from a dict
|
||||||
|
info_from_dict = Info.from_dict(info_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# PrimitiveString
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**value** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of PrimitiveString from a JSON string
|
||||||
|
primitive_string_instance = PrimitiveString.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print PrimitiveString.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
primitive_string_dict = primitive_string_instance.to_dict()
|
||||||
|
# create an instance of PrimitiveString from a dict
|
||||||
|
primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_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)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -86,6 +87,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -114,6 +116,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -61,6 +62,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -89,6 +91,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Optional, Union
|
||||||
|
from pydantic import BaseModel, Field, StrictStr
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
from importlib import import_module
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class BaseDiscriminator(BaseModel):
|
||||||
|
"""
|
||||||
|
BaseDiscriminator
|
||||||
|
"""
|
||||||
|
type_name: Optional[StrictStr] = Field(default=None, alias="_typeName")
|
||||||
|
__properties = ["_typeName"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
# JSON field name that stores the object type
|
||||||
|
__discriminator_property_name = '_typeName'
|
||||||
|
|
||||||
|
# discriminator mappings
|
||||||
|
__discriminator_value_class_map = {
|
||||||
|
'string': 'PrimitiveString',
|
||||||
|
'Info': 'Info'
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_discriminator_value(cls, obj: dict) -> str:
|
||||||
|
"""Returns the discriminator value (object type) of the data"""
|
||||||
|
discriminator_value = obj[cls.__discriminator_property_name]
|
||||||
|
if discriminator_value:
|
||||||
|
return cls.__discriminator_value_class_map.get(discriminator_value)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Union(Info, PrimitiveString):
|
||||||
|
"""Create an instance of BaseDiscriminator from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> Union(Info, PrimitiveString):
|
||||||
|
"""Create an instance of BaseDiscriminator from a dict"""
|
||||||
|
# look up the object type based on discriminator mapping
|
||||||
|
object_type = cls.get_discriminator_value(obj)
|
||||||
|
if object_type == 'PrimitiveString':
|
||||||
|
return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj)
|
||||||
|
if object_type == 'Info':
|
||||||
|
return import_module("petstore_api.models.info").Info.from_dict(obj)
|
||||||
|
raise ValueError("BaseDiscriminator failed to lookup discriminator value from " +
|
||||||
|
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
|
||||||
|
", mapping: " + json.dumps(cls.__discriminator_value_class_map))
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class Info(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
Info
|
||||||
|
"""
|
||||||
|
val: Optional[BaseDiscriminator] = None
|
||||||
|
__properties = ["_typeName", "val"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Info:
|
||||||
|
"""Create an instance of Info from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of val
|
||||||
|
if self.val:
|
||||||
|
_dict['val'] = self.val.to_dict()
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> Info:
|
||||||
|
"""Create an instance of Info from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return Info.parse_obj(obj)
|
||||||
|
|
||||||
|
_obj = Info.parse_obj({
|
||||||
|
"type_name": obj.get("_typeName"),
|
||||||
|
"val": BaseDiscriminator.from_dict(obj.get("val")) if obj.get("val") is not None else None
|
||||||
|
})
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
from pydantic import Field, StrictStr
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class PrimitiveString(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
PrimitiveString
|
||||||
|
"""
|
||||||
|
value: Optional[StrictStr] = Field(default=None, alias="_value")
|
||||||
|
__properties = ["_typeName", "_value"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> PrimitiveString:
|
||||||
|
"""Create an instance of PrimitiveString from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> PrimitiveString:
|
||||||
|
"""Create an instance of PrimitiveString from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return PrimitiveString.parse_obj(obj)
|
||||||
|
|
||||||
|
_obj = PrimitiveString.parse_obj({
|
||||||
|
"type_name": obj.get("_typeName"),
|
||||||
|
"value": obj.get("_value")
|
||||||
|
})
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator # noqa: E501
|
||||||
|
|
||||||
|
class TestBaseDiscriminator(unittest.TestCase):
|
||||||
|
"""BaseDiscriminator unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> BaseDiscriminator:
|
||||||
|
"""Test BaseDiscriminator
|
||||||
|
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 `BaseDiscriminator`
|
||||||
|
"""
|
||||||
|
model = BaseDiscriminator() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
type_name = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testBaseDiscriminator(self):
|
||||||
|
"""Test BaseDiscriminator"""
|
||||||
|
# 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,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.info import Info # noqa: E501
|
||||||
|
|
||||||
|
class TestInfo(unittest.TestCase):
|
||||||
|
"""Info unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> Info:
|
||||||
|
"""Test Info
|
||||||
|
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 `Info`
|
||||||
|
"""
|
||||||
|
model = Info() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return Info(
|
||||||
|
val = petstore_api.models.base_discriminator.BaseDiscriminator()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Info(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testInfo(self):
|
||||||
|
"""Test Info"""
|
||||||
|
# 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,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString # noqa: E501
|
||||||
|
|
||||||
|
class TestPrimitiveString(unittest.TestCase):
|
||||||
|
"""PrimitiveString unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> PrimitiveString:
|
||||||
|
"""Test PrimitiveString
|
||||||
|
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 `PrimitiveString`
|
||||||
|
"""
|
||||||
|
model = PrimitiveString() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return PrimitiveString(
|
||||||
|
value = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return PrimitiveString(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testPrimitiveString(self):
|
||||||
|
"""Test PrimitiveString"""
|
||||||
|
# inst_req_only = self.make_instance(include_optional=False)
|
||||||
|
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -18,6 +18,7 @@ docs/ArrayOfArrayOfModel.md
|
|||||||
docs/ArrayOfArrayOfNumberOnly.md
|
docs/ArrayOfArrayOfNumberOnly.md
|
||||||
docs/ArrayOfNumberOnly.md
|
docs/ArrayOfNumberOnly.md
|
||||||
docs/ArrayTest.md
|
docs/ArrayTest.md
|
||||||
|
docs/BaseDiscriminator.md
|
||||||
docs/BasquePig.md
|
docs/BasquePig.md
|
||||||
docs/Bathing.md
|
docs/Bathing.md
|
||||||
docs/Capitalization.md
|
docs/Capitalization.md
|
||||||
@@ -55,6 +56,7 @@ docs/FormatTest.md
|
|||||||
docs/HasOnlyReadOnly.md
|
docs/HasOnlyReadOnly.md
|
||||||
docs/HealthCheckResult.md
|
docs/HealthCheckResult.md
|
||||||
docs/ImportTestDatetimeApi.md
|
docs/ImportTestDatetimeApi.md
|
||||||
|
docs/Info.md
|
||||||
docs/InnerDictWithProperty.md
|
docs/InnerDictWithProperty.md
|
||||||
docs/InputAllOf.md
|
docs/InputAllOf.md
|
||||||
docs/IntOrString.md
|
docs/IntOrString.md
|
||||||
@@ -84,6 +86,7 @@ docs/Pet.md
|
|||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
docs/Pig.md
|
docs/Pig.md
|
||||||
docs/PoopCleaning.md
|
docs/PoopCleaning.md
|
||||||
|
docs/PrimitiveString.md
|
||||||
docs/PropertyMap.md
|
docs/PropertyMap.md
|
||||||
docs/PropertyNameCollision.md
|
docs/PropertyNameCollision.md
|
||||||
docs/ReadOnlyFirst.md
|
docs/ReadOnlyFirst.md
|
||||||
@@ -138,6 +141,7 @@ petstore_api/models/array_of_array_of_model.py
|
|||||||
petstore_api/models/array_of_array_of_number_only.py
|
petstore_api/models/array_of_array_of_number_only.py
|
||||||
petstore_api/models/array_of_number_only.py
|
petstore_api/models/array_of_number_only.py
|
||||||
petstore_api/models/array_test.py
|
petstore_api/models/array_test.py
|
||||||
|
petstore_api/models/base_discriminator.py
|
||||||
petstore_api/models/basque_pig.py
|
petstore_api/models/basque_pig.py
|
||||||
petstore_api/models/bathing.py
|
petstore_api/models/bathing.py
|
||||||
petstore_api/models/capitalization.py
|
petstore_api/models/capitalization.py
|
||||||
@@ -171,6 +175,7 @@ petstore_api/models/foo_get_default_response.py
|
|||||||
petstore_api/models/format_test.py
|
petstore_api/models/format_test.py
|
||||||
petstore_api/models/has_only_read_only.py
|
petstore_api/models/has_only_read_only.py
|
||||||
petstore_api/models/health_check_result.py
|
petstore_api/models/health_check_result.py
|
||||||
|
petstore_api/models/info.py
|
||||||
petstore_api/models/inner_dict_with_property.py
|
petstore_api/models/inner_dict_with_property.py
|
||||||
petstore_api/models/input_all_of.py
|
petstore_api/models/input_all_of.py
|
||||||
petstore_api/models/int_or_string.py
|
petstore_api/models/int_or_string.py
|
||||||
@@ -199,6 +204,7 @@ petstore_api/models/parent_with_optional_dict.py
|
|||||||
petstore_api/models/pet.py
|
petstore_api/models/pet.py
|
||||||
petstore_api/models/pig.py
|
petstore_api/models/pig.py
|
||||||
petstore_api/models/poop_cleaning.py
|
petstore_api/models/poop_cleaning.py
|
||||||
|
petstore_api/models/primitive_string.py
|
||||||
petstore_api/models/property_map.py
|
petstore_api/models/property_map.py
|
||||||
petstore_api/models/property_name_collision.py
|
petstore_api/models/property_name_collision.py
|
||||||
petstore_api/models/read_only_first.py
|
petstore_api/models/read_only_first.py
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
- [ArrayTest](docs/ArrayTest.md)
|
- [ArrayTest](docs/ArrayTest.md)
|
||||||
|
- [BaseDiscriminator](docs/BaseDiscriminator.md)
|
||||||
- [BasquePig](docs/BasquePig.md)
|
- [BasquePig](docs/BasquePig.md)
|
||||||
- [Bathing](docs/Bathing.md)
|
- [Bathing](docs/Bathing.md)
|
||||||
- [Capitalization](docs/Capitalization.md)
|
- [Capitalization](docs/Capitalization.md)
|
||||||
@@ -198,6 +199,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [FormatTest](docs/FormatTest.md)
|
- [FormatTest](docs/FormatTest.md)
|
||||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||||
|
- [Info](docs/Info.md)
|
||||||
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
||||||
- [InputAllOf](docs/InputAllOf.md)
|
- [InputAllOf](docs/InputAllOf.md)
|
||||||
- [IntOrString](docs/IntOrString.md)
|
- [IntOrString](docs/IntOrString.md)
|
||||||
@@ -226,6 +228,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [Pig](docs/Pig.md)
|
- [Pig](docs/Pig.md)
|
||||||
- [PoopCleaning](docs/PoopCleaning.md)
|
- [PoopCleaning](docs/PoopCleaning.md)
|
||||||
|
- [PrimitiveString](docs/PrimitiveString.md)
|
||||||
- [PropertyMap](docs/PropertyMap.md)
|
- [PropertyMap](docs/PropertyMap.md)
|
||||||
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
||||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# BaseDiscriminator
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**type_name** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of BaseDiscriminator from a JSON string
|
||||||
|
base_discriminator_instance = BaseDiscriminator.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print BaseDiscriminator.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
base_discriminator_dict = base_discriminator_instance.to_dict()
|
||||||
|
# create an instance of BaseDiscriminator from a dict
|
||||||
|
base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Info
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**val** | [**BaseDiscriminator**](BaseDiscriminator.md) | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of Info from a JSON string
|
||||||
|
info_instance = Info.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print Info.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
info_dict = info_instance.to_dict()
|
||||||
|
# create an instance of Info from a dict
|
||||||
|
info_from_dict = Info.from_dict(info_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# PrimitiveString
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**value** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of PrimitiveString from a JSON string
|
||||||
|
primitive_string_instance = PrimitiveString.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print PrimitiveString.to_json()
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
primitive_string_dict = primitive_string_instance.to_dict()
|
||||||
|
# create an instance of PrimitiveString from a dict
|
||||||
|
primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_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)
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -86,6 +87,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -114,6 +116,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -61,6 +62,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -89,6 +91,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Any, Dict, Optional, Union
|
||||||
|
from pydantic import BaseModel, Field, StrictStr
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
from importlib import import_module
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class BaseDiscriminator(BaseModel):
|
||||||
|
"""
|
||||||
|
BaseDiscriminator
|
||||||
|
"""
|
||||||
|
type_name: Optional[StrictStr] = Field(default=None, alias="_typeName")
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties = ["_typeName"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
# JSON field name that stores the object type
|
||||||
|
__discriminator_property_name = '_typeName'
|
||||||
|
|
||||||
|
# discriminator mappings
|
||||||
|
__discriminator_value_class_map = {
|
||||||
|
'string': 'PrimitiveString',
|
||||||
|
'Info': 'Info'
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_discriminator_value(cls, obj: dict) -> str:
|
||||||
|
"""Returns the discriminator value (object type) of the data"""
|
||||||
|
discriminator_value = obj[cls.__discriminator_property_name]
|
||||||
|
if discriminator_value:
|
||||||
|
return cls.__discriminator_value_class_map.get(discriminator_value)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Union(Info, PrimitiveString):
|
||||||
|
"""Create an instance of BaseDiscriminator from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
"additional_properties"
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> Union(Info, PrimitiveString):
|
||||||
|
"""Create an instance of BaseDiscriminator from a dict"""
|
||||||
|
# look up the object type based on discriminator mapping
|
||||||
|
object_type = cls.get_discriminator_value(obj)
|
||||||
|
if object_type == 'PrimitiveString':
|
||||||
|
return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj)
|
||||||
|
if object_type == 'Info':
|
||||||
|
return import_module("petstore_api.models.info").Info.from_dict(obj)
|
||||||
|
raise ValueError("BaseDiscriminator failed to lookup discriminator value from " +
|
||||||
|
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
|
||||||
|
", mapping: " + json.dumps(cls.__discriminator_value_class_map))
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class Info(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
Info
|
||||||
|
"""
|
||||||
|
val: Optional[BaseDiscriminator] = None
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties = ["_typeName", "val"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Info:
|
||||||
|
"""Create an instance of Info from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
"additional_properties"
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of val
|
||||||
|
if self.val:
|
||||||
|
_dict['val'] = self.val.to_dict()
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> Info:
|
||||||
|
"""Create an instance of Info from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return Info.parse_obj(obj)
|
||||||
|
|
||||||
|
_obj = Info.parse_obj({
|
||||||
|
"type_name": obj.get("_typeName"),
|
||||||
|
"val": BaseDiscriminator.from_dict(obj.get("val")) if obj.get("val") is not None else None
|
||||||
|
})
|
||||||
|
# store additional fields in additional_properties
|
||||||
|
for _key in obj.keys():
|
||||||
|
if _key not in cls.__properties:
|
||||||
|
_obj.additional_properties[_key] = obj.get(_key)
|
||||||
|
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
from pydantic import Field, StrictStr
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class PrimitiveString(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
PrimitiveString
|
||||||
|
"""
|
||||||
|
value: Optional[StrictStr] = Field(default=None, alias="_value")
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties = ["_typeName", "_value"]
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
"""Pydantic configuration"""
|
||||||
|
allow_population_by_field_name = True
|
||||||
|
validate_assignment = True
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.dict(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> PrimitiveString:
|
||||||
|
"""Create an instance of PrimitiveString from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
"""Returns the dictionary representation of the model using alias"""
|
||||||
|
_dict = self.dict(by_alias=True,
|
||||||
|
exclude={
|
||||||
|
"additional_properties"
|
||||||
|
},
|
||||||
|
exclude_none=True)
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: dict) -> PrimitiveString:
|
||||||
|
"""Create an instance of PrimitiveString from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return PrimitiveString.parse_obj(obj)
|
||||||
|
|
||||||
|
_obj = PrimitiveString.parse_obj({
|
||||||
|
"type_name": obj.get("_typeName"),
|
||||||
|
"value": obj.get("_value")
|
||||||
|
})
|
||||||
|
# store additional fields in additional_properties
|
||||||
|
for _key in obj.keys():
|
||||||
|
if _key not in cls.__properties:
|
||||||
|
_obj.additional_properties[_key] = obj.get(_key)
|
||||||
|
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator # noqa: E501
|
||||||
|
|
||||||
|
class TestBaseDiscriminator(unittest.TestCase):
|
||||||
|
"""BaseDiscriminator unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> BaseDiscriminator:
|
||||||
|
"""Test BaseDiscriminator
|
||||||
|
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 `BaseDiscriminator`
|
||||||
|
"""
|
||||||
|
model = BaseDiscriminator() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
type_name = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testBaseDiscriminator(self):
|
||||||
|
"""Test BaseDiscriminator"""
|
||||||
|
# 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,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.info import Info # noqa: E501
|
||||||
|
|
||||||
|
class TestInfo(unittest.TestCase):
|
||||||
|
"""Info unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> Info:
|
||||||
|
"""Test Info
|
||||||
|
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 `Info`
|
||||||
|
"""
|
||||||
|
model = Info() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return Info(
|
||||||
|
val = petstore_api.models.base_discriminator.BaseDiscriminator()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Info(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testInfo(self):
|
||||||
|
"""Test Info"""
|
||||||
|
# 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,52 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString # noqa: E501
|
||||||
|
|
||||||
|
class TestPrimitiveString(unittest.TestCase):
|
||||||
|
"""PrimitiveString unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> PrimitiveString:
|
||||||
|
"""Test PrimitiveString
|
||||||
|
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 `PrimitiveString`
|
||||||
|
"""
|
||||||
|
model = PrimitiveString() # noqa: E501
|
||||||
|
if include_optional:
|
||||||
|
return PrimitiveString(
|
||||||
|
value = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return PrimitiveString(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testPrimitiveString(self):
|
||||||
|
"""Test PrimitiveString"""
|
||||||
|
# inst_req_only = self.make_instance(include_optional=False)
|
||||||
|
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -17,6 +17,7 @@ docs/ArrayOfArrayOfModel.md
|
|||||||
docs/ArrayOfArrayOfNumberOnly.md
|
docs/ArrayOfArrayOfNumberOnly.md
|
||||||
docs/ArrayOfNumberOnly.md
|
docs/ArrayOfNumberOnly.md
|
||||||
docs/ArrayTest.md
|
docs/ArrayTest.md
|
||||||
|
docs/BaseDiscriminator.md
|
||||||
docs/BasquePig.md
|
docs/BasquePig.md
|
||||||
docs/Bathing.md
|
docs/Bathing.md
|
||||||
docs/Capitalization.md
|
docs/Capitalization.md
|
||||||
@@ -53,6 +54,7 @@ docs/FormatTest.md
|
|||||||
docs/HasOnlyReadOnly.md
|
docs/HasOnlyReadOnly.md
|
||||||
docs/HealthCheckResult.md
|
docs/HealthCheckResult.md
|
||||||
docs/ImportTestDatetimeApi.md
|
docs/ImportTestDatetimeApi.md
|
||||||
|
docs/Info.md
|
||||||
docs/InnerDictWithProperty.md
|
docs/InnerDictWithProperty.md
|
||||||
docs/InputAllOf.md
|
docs/InputAllOf.md
|
||||||
docs/IntOrString.md
|
docs/IntOrString.md
|
||||||
@@ -84,6 +86,7 @@ docs/Pet.md
|
|||||||
docs/PetApi.md
|
docs/PetApi.md
|
||||||
docs/Pig.md
|
docs/Pig.md
|
||||||
docs/PoopCleaning.md
|
docs/PoopCleaning.md
|
||||||
|
docs/PrimitiveString.md
|
||||||
docs/PropertyMap.md
|
docs/PropertyMap.md
|
||||||
docs/PropertyNameCollision.md
|
docs/PropertyNameCollision.md
|
||||||
docs/ReadOnlyFirst.md
|
docs/ReadOnlyFirst.md
|
||||||
@@ -137,6 +140,7 @@ petstore_api/models/array_of_array_of_model.py
|
|||||||
petstore_api/models/array_of_array_of_number_only.py
|
petstore_api/models/array_of_array_of_number_only.py
|
||||||
petstore_api/models/array_of_number_only.py
|
petstore_api/models/array_of_number_only.py
|
||||||
petstore_api/models/array_test.py
|
petstore_api/models/array_test.py
|
||||||
|
petstore_api/models/base_discriminator.py
|
||||||
petstore_api/models/basque_pig.py
|
petstore_api/models/basque_pig.py
|
||||||
petstore_api/models/bathing.py
|
petstore_api/models/bathing.py
|
||||||
petstore_api/models/capitalization.py
|
petstore_api/models/capitalization.py
|
||||||
@@ -169,6 +173,7 @@ petstore_api/models/foo_get_default_response.py
|
|||||||
petstore_api/models/format_test.py
|
petstore_api/models/format_test.py
|
||||||
petstore_api/models/has_only_read_only.py
|
petstore_api/models/has_only_read_only.py
|
||||||
petstore_api/models/health_check_result.py
|
petstore_api/models/health_check_result.py
|
||||||
|
petstore_api/models/info.py
|
||||||
petstore_api/models/inner_dict_with_property.py
|
petstore_api/models/inner_dict_with_property.py
|
||||||
petstore_api/models/input_all_of.py
|
petstore_api/models/input_all_of.py
|
||||||
petstore_api/models/int_or_string.py
|
petstore_api/models/int_or_string.py
|
||||||
@@ -199,6 +204,7 @@ petstore_api/models/parent_with_optional_dict.py
|
|||||||
petstore_api/models/pet.py
|
petstore_api/models/pet.py
|
||||||
petstore_api/models/pig.py
|
petstore_api/models/pig.py
|
||||||
petstore_api/models/poop_cleaning.py
|
petstore_api/models/poop_cleaning.py
|
||||||
|
petstore_api/models/primitive_string.py
|
||||||
petstore_api/models/property_map.py
|
petstore_api/models/property_map.py
|
||||||
petstore_api/models/property_name_collision.py
|
petstore_api/models/property_name_collision.py
|
||||||
petstore_api/models/read_only_first.py
|
petstore_api/models/read_only_first.py
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
- [ArrayTest](docs/ArrayTest.md)
|
- [ArrayTest](docs/ArrayTest.md)
|
||||||
|
- [BaseDiscriminator](docs/BaseDiscriminator.md)
|
||||||
- [BasquePig](docs/BasquePig.md)
|
- [BasquePig](docs/BasquePig.md)
|
||||||
- [Bathing](docs/Bathing.md)
|
- [Bathing](docs/Bathing.md)
|
||||||
- [Capitalization](docs/Capitalization.md)
|
- [Capitalization](docs/Capitalization.md)
|
||||||
@@ -195,6 +196,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [FormatTest](docs/FormatTest.md)
|
- [FormatTest](docs/FormatTest.md)
|
||||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||||
|
- [Info](docs/Info.md)
|
||||||
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
- [InnerDictWithProperty](docs/InnerDictWithProperty.md)
|
||||||
- [InputAllOf](docs/InputAllOf.md)
|
- [InputAllOf](docs/InputAllOf.md)
|
||||||
- [IntOrString](docs/IntOrString.md)
|
- [IntOrString](docs/IntOrString.md)
|
||||||
@@ -225,6 +227,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [Pig](docs/Pig.md)
|
- [Pig](docs/Pig.md)
|
||||||
- [PoopCleaning](docs/PoopCleaning.md)
|
- [PoopCleaning](docs/PoopCleaning.md)
|
||||||
|
- [PrimitiveString](docs/PrimitiveString.md)
|
||||||
- [PropertyMap](docs/PropertyMap.md)
|
- [PropertyMap](docs/PropertyMap.md)
|
||||||
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
- [PropertyNameCollision](docs/PropertyNameCollision.md)
|
||||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# BaseDiscriminator
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**type_name** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of BaseDiscriminator from a JSON string
|
||||||
|
base_discriminator_instance = BaseDiscriminator.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(BaseDiscriminator.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
base_discriminator_dict = base_discriminator_instance.to_dict()
|
||||||
|
# create an instance of BaseDiscriminator from a dict
|
||||||
|
base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_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)
|
||||||
|
|
||||||
|
|
||||||
29
samples/openapi3/client/petstore/python/docs/Info.md
Normal file
29
samples/openapi3/client/petstore/python/docs/Info.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Info
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**val** | [**BaseDiscriminator**](BaseDiscriminator.md) | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of Info from a JSON string
|
||||||
|
info_instance = Info.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(Info.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
info_dict = info_instance.to_dict()
|
||||||
|
# create an instance of Info from a dict
|
||||||
|
info_from_dict = Info.from_dict(info_dict)
|
||||||
|
```
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# PrimitiveString
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**value** | **str** | | [optional]
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
# TODO update the JSON string below
|
||||||
|
json = "{}"
|
||||||
|
# create an instance of PrimitiveString from a JSON string
|
||||||
|
primitive_string_instance = PrimitiveString.from_json(json)
|
||||||
|
# print the JSON string representation of the object
|
||||||
|
print(PrimitiveString.to_json())
|
||||||
|
|
||||||
|
# convert the object into a dict
|
||||||
|
primitive_string_dict = primitive_string_instance.to_dict()
|
||||||
|
# create an instance of PrimitiveString from a dict
|
||||||
|
primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_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)
|
||||||
|
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -84,6 +85,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -114,6 +116,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ 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_array_of_number_only import ArrayOfArrayOfNumberOnly
|
||||||
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
from petstore_api.models.array_of_number_only import ArrayOfNumberOnly
|
||||||
from petstore_api.models.array_test import ArrayTest
|
from petstore_api.models.array_test import ArrayTest
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
from petstore_api.models.basque_pig import BasquePig
|
from petstore_api.models.basque_pig import BasquePig
|
||||||
from petstore_api.models.bathing import Bathing
|
from petstore_api.models.bathing import Bathing
|
||||||
from petstore_api.models.capitalization import Capitalization
|
from petstore_api.models.capitalization import Capitalization
|
||||||
@@ -59,6 +60,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse
|
|||||||
from petstore_api.models.format_test import FormatTest
|
from petstore_api.models.format_test import FormatTest
|
||||||
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
from petstore_api.models.has_only_read_only import HasOnlyReadOnly
|
||||||
from petstore_api.models.health_check_result import HealthCheckResult
|
from petstore_api.models.health_check_result import HealthCheckResult
|
||||||
|
from petstore_api.models.info import Info
|
||||||
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
from petstore_api.models.inner_dict_with_property import InnerDictWithProperty
|
||||||
from petstore_api.models.input_all_of import InputAllOf
|
from petstore_api.models.input_all_of import InputAllOf
|
||||||
from petstore_api.models.int_or_string import IntOrString
|
from petstore_api.models.int_or_string import IntOrString
|
||||||
@@ -89,6 +91,7 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict
|
|||||||
from petstore_api.models.pet import Pet
|
from petstore_api.models.pet import Pet
|
||||||
from petstore_api.models.pig import Pig
|
from petstore_api.models.pig import Pig
|
||||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
from petstore_api.models.property_map import PropertyMap
|
from petstore_api.models.property_map import PropertyMap
|
||||||
from petstore_api.models.property_name_collision import PropertyNameCollision
|
from petstore_api.models.property_name_collision import PropertyNameCollision
|
||||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from importlib import import_module
|
||||||
|
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class BaseDiscriminator(BaseModel):
|
||||||
|
"""
|
||||||
|
BaseDiscriminator
|
||||||
|
""" # noqa: E501
|
||||||
|
type_name: Optional[StrictStr] = Field(default=None, alias="_typeName")
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# JSON field name that stores the object type
|
||||||
|
__discriminator_property_name: ClassVar[str] = '_typeName'
|
||||||
|
|
||||||
|
# discriminator mappings
|
||||||
|
__discriminator_value_class_map: ClassVar[Dict[str, str]] = {
|
||||||
|
'string': 'PrimitiveString','Info': 'Info'
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]:
|
||||||
|
"""Returns the discriminator value (object type) of the data"""
|
||||||
|
discriminator_value = obj[cls.__discriminator_property_name]
|
||||||
|
if discriminator_value:
|
||||||
|
return cls.__discriminator_value_class_map.get(discriminator_value)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]:
|
||||||
|
"""Create an instance of BaseDiscriminator from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
* Fields in `self.additional_properties` are added to the output dict.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
"additional_properties",
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]:
|
||||||
|
"""Create an instance of BaseDiscriminator from a dict"""
|
||||||
|
# look up the object type based on discriminator mapping
|
||||||
|
object_type = cls.get_discriminator_value(obj)
|
||||||
|
if object_type == 'PrimitiveString':
|
||||||
|
return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj)
|
||||||
|
if object_type == 'Info':
|
||||||
|
return import_module("petstore_api.models.info").Info.from_dict(obj)
|
||||||
|
|
||||||
|
raise ValueError("BaseDiscriminator failed to lookup discriminator value from " +
|
||||||
|
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
|
||||||
|
", mapping: " + json.dumps(cls.__discriminator_value_class_map))
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from pydantic import ConfigDict
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
class Info(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
Info
|
||||||
|
""" # noqa: E501
|
||||||
|
val: Optional[BaseDiscriminator] = None
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName", "val"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
|
"""Create an instance of Info from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
* Fields in `self.additional_properties` are added to the output dict.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
"additional_properties",
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
# override the default output from pydantic by calling `to_dict()` of val
|
||||||
|
if self.val:
|
||||||
|
_dict['val'] = self.val.to_dict()
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||||
|
"""Create an instance of Info from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return cls.model_validate(obj)
|
||||||
|
|
||||||
|
_obj = cls.model_validate({
|
||||||
|
"_typeName": obj.get("_typeName"),
|
||||||
|
"val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None
|
||||||
|
})
|
||||||
|
# store additional fields in additional_properties
|
||||||
|
for _key in obj.keys():
|
||||||
|
if _key not in cls.__properties:
|
||||||
|
_obj.additional_properties[_key] = obj.get(_key)
|
||||||
|
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
import pprint
|
||||||
|
import re # noqa: F401
|
||||||
|
import json
|
||||||
|
|
||||||
|
from pydantic import ConfigDict, Field, StrictStr
|
||||||
|
from typing import Any, ClassVar, Dict, List, Optional
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
from typing import Optional, Set
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
class PrimitiveString(BaseDiscriminator):
|
||||||
|
"""
|
||||||
|
PrimitiveString
|
||||||
|
""" # noqa: E501
|
||||||
|
value: Optional[StrictStr] = Field(default=None, alias="_value")
|
||||||
|
additional_properties: Dict[str, Any] = {}
|
||||||
|
__properties: ClassVar[List[str]] = ["_typeName", "_value"]
|
||||||
|
|
||||||
|
model_config = ConfigDict(
|
||||||
|
populate_by_name=True,
|
||||||
|
validate_assignment=True,
|
||||||
|
protected_namespaces=(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def to_str(self) -> str:
|
||||||
|
"""Returns the string representation of the model using alias"""
|
||||||
|
return pprint.pformat(self.model_dump(by_alias=True))
|
||||||
|
|
||||||
|
def to_json(self) -> str:
|
||||||
|
"""Returns the JSON representation of the model using alias"""
|
||||||
|
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
||||||
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||||
|
"""Create an instance of PrimitiveString from a JSON string"""
|
||||||
|
return cls.from_dict(json.loads(json_str))
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
"""Return the dictionary representation of the model using alias.
|
||||||
|
|
||||||
|
This has the following differences from calling pydantic's
|
||||||
|
`self.model_dump(by_alias=True)`:
|
||||||
|
|
||||||
|
* `None` is only added to the output dict for nullable fields that
|
||||||
|
were set at model initialization. Other fields with value `None`
|
||||||
|
are ignored.
|
||||||
|
* Fields in `self.additional_properties` are added to the output dict.
|
||||||
|
"""
|
||||||
|
excluded_fields: Set[str] = set([
|
||||||
|
"additional_properties",
|
||||||
|
])
|
||||||
|
|
||||||
|
_dict = self.model_dump(
|
||||||
|
by_alias=True,
|
||||||
|
exclude=excluded_fields,
|
||||||
|
exclude_none=True,
|
||||||
|
)
|
||||||
|
# puts key-value pairs in additional_properties in the top level
|
||||||
|
if self.additional_properties is not None:
|
||||||
|
for _key, _value in self.additional_properties.items():
|
||||||
|
_dict[_key] = _value
|
||||||
|
|
||||||
|
return _dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||||
|
"""Create an instance of PrimitiveString from a dict"""
|
||||||
|
if obj is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not isinstance(obj, dict):
|
||||||
|
return cls.model_validate(obj)
|
||||||
|
|
||||||
|
_obj = cls.model_validate({
|
||||||
|
"_typeName": obj.get("_typeName"),
|
||||||
|
"_value": obj.get("_value")
|
||||||
|
})
|
||||||
|
# store additional fields in additional_properties
|
||||||
|
for _key in obj.keys():
|
||||||
|
if _key not in cls.__properties:
|
||||||
|
_obj.additional_properties[_key] = obj.get(_key)
|
||||||
|
|
||||||
|
return _obj
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.base_discriminator import BaseDiscriminator
|
||||||
|
|
||||||
|
class TestBaseDiscriminator(unittest.TestCase):
|
||||||
|
"""BaseDiscriminator unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> BaseDiscriminator:
|
||||||
|
"""Test BaseDiscriminator
|
||||||
|
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 `BaseDiscriminator`
|
||||||
|
"""
|
||||||
|
model = BaseDiscriminator()
|
||||||
|
if include_optional:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
type_name = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return BaseDiscriminator(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testBaseDiscriminator(self):
|
||||||
|
"""Test BaseDiscriminator"""
|
||||||
|
# inst_req_only = self.make_instance(include_optional=False)
|
||||||
|
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
51
samples/openapi3/client/petstore/python/test/test_info.py
Normal file
51
samples/openapi3/client/petstore/python/test/test_info.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.info import Info
|
||||||
|
|
||||||
|
class TestInfo(unittest.TestCase):
|
||||||
|
"""Info unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> Info:
|
||||||
|
"""Test Info
|
||||||
|
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 `Info`
|
||||||
|
"""
|
||||||
|
model = Info()
|
||||||
|
if include_optional:
|
||||||
|
return Info(
|
||||||
|
val = petstore_api.models.base_discriminator.BaseDiscriminator()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Info(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testInfo(self):
|
||||||
|
"""Test Info"""
|
||||||
|
# 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,51 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
OpenAPI Petstore
|
||||||
|
|
||||||
|
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
|
||||||
|
The version of the OpenAPI document: 1.0.0
|
||||||
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
""" # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from petstore_api.models.primitive_string import PrimitiveString
|
||||||
|
|
||||||
|
class TestPrimitiveString(unittest.TestCase):
|
||||||
|
"""PrimitiveString unit test stubs"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make_instance(self, include_optional) -> PrimitiveString:
|
||||||
|
"""Test PrimitiveString
|
||||||
|
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 `PrimitiveString`
|
||||||
|
"""
|
||||||
|
model = PrimitiveString()
|
||||||
|
if include_optional:
|
||||||
|
return PrimitiveString(
|
||||||
|
value = ''
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return PrimitiveString(
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def testPrimitiveString(self):
|
||||||
|
"""Test PrimitiveString"""
|
||||||
|
# inst_req_only = self.make_instance(include_optional=False)
|
||||||
|
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -629,6 +629,13 @@ class ModelTests(unittest.TestCase):
|
|||||||
self.assertEqual(model_a.to_json(), '{"_name": "nameA", "second_circular_all_of_ref": {"name": "nameB"}}')
|
self.assertEqual(model_a.to_json(), '{"_name": "nameA", "second_circular_all_of_ref": {"name": "nameB"}}')
|
||||||
self.assertEqual(model_b.to_json(), '{"_name": "nameB", "circular_all_of_ref": {"name": "nameA"}}')
|
self.assertEqual(model_b.to_json(), '{"_name": "nameB", "circular_all_of_ref": {"name": "nameA"}}')
|
||||||
|
|
||||||
|
def test_allof_discriminator_mapping(self):
|
||||||
|
# for issue 18498
|
||||||
|
user_info_json = '{"_typeName": "Info", "val": {"_typeName": "string", "_value": "some string"}}'
|
||||||
|
user_info = petstore_api.models.Info.from_json(user_info_json)
|
||||||
|
# shouldn't throw ValueError("BaseDiscriminator failed to lookup discriminator value...")
|
||||||
|
assert user_info is not None
|
||||||
|
self.assertEqual(user_info.to_json(), user_info_json)
|
||||||
|
|
||||||
class TestdditionalPropertiesAnyType(unittest.TestCase):
|
class TestdditionalPropertiesAnyType(unittest.TestCase):
|
||||||
def test_additional_properties(self):
|
def test_additional_properties(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user