diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py index 61c8c56c3..091141e5a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/__init__.py @@ -10,6 +10,7 @@ from .free_form_model import FreeFormModel from .http_validation_error import HTTPValidationError from .model_from_all_of import ModelFromAllOf +from .model_from_one_of import ModelFromOneOf from .model_with_additional_properties_inlined import ModelWithAdditionalPropertiesInlined from .model_with_additional_properties_inlined_additional_property import ( ModelWithAdditionalPropertiesInlinedAdditionalProperty, diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py index ce26a3bbb..dc7f876a3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, Dict, Type, TypeVar, Union import attr @@ -13,14 +13,12 @@ class ModelFromAllOf: a_sub_property: Union[Unset, str] = UNSET another_sub_property: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: a_sub_property = self.a_sub_property another_sub_property = self.another_sub_property field_dict: Dict[str, Any] = {} - field_dict.update(self.additional_properties) field_dict.update({}) if a_sub_property is not UNSET: field_dict["a_sub_property"] = a_sub_property @@ -41,21 +39,4 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: another_sub_property=another_sub_property, ) - model_from_all_of.additional_properties = d return model_from_all_of - - @property - def additional_keys(self) -> List[str]: - return list(self.additional_properties.keys()) - - def __getitem__(self, key: str) -> Any: - return self.additional_properties[key] - - def __setitem__(self, key: str, value: Any) -> None: - self.additional_properties[key] = value - - def __delitem__(self, key: str) -> None: - del self.additional_properties[key] - - def __contains__(self, key: str) -> bool: - return key in self.additional_properties diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_one_of.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_one_of.py new file mode 100644 index 000000000..0f222c329 --- /dev/null +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_one_of.py @@ -0,0 +1,44 @@ +from typing import Any, Dict, List, Type, TypeVar + +import attr + +T = TypeVar("T", bound="ModelFromOneOf") + + +@attr.s(auto_attribs=True) +class ModelFromOneOf: + """ """ + + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) + + def to_dict(self) -> Dict[str, Any]: + + field_dict: Dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + + return field_dict + + @classmethod + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + d = src_dict.copy() + model_from_one_of = cls() + + model_from_one_of.additional_properties = d + return model_from_one_of + + @property + def additional_keys(self) -> List[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/openapi.json b/end_to_end_tests/openapi.json index ed0de8918..19173119c 100644 --- a/end_to_end_tests/openapi.json +++ b/end_to_end_tests/openapi.json @@ -1098,11 +1098,20 @@ "ModelFromAllOf": { "title": "ModelFromAllOf", "type": "object", + "additionalProperties": false, "allOf": [ {"$ref": "#/components/schemas/AllOfSubModel"}, {"$ref": "#/components/schemas/AnotherAllOfSubModel"} ] }, + "ModelFromOneOf": { + "title": "ModelFromOneOf", + "type": "object", + "oneOf": [ + {"$ref": "#/components/schemas/AllOfSubModel"}, + {"$ref": "#/components/schemas/AnotherAllOfSubModel"} + ] + }, "AllOfSubModel": { "title": "AllOfSubModel", "type": "object",