Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!:Allow more types in multipart payloads by defaulting to JSON fo…
…r complex types (#372). Thanks @csymeonides-mf! * fix: Detect File fields correctly * fix: Optional File field caused missing import error * fix: Non-string multipart fields must be stringified * chore: Reformat * fix: Put non-file fields as tuples in the files dict * refactor: Avoid runtime type checks * fix: Declaring types is necessary * fix: Remove dead code * fix: Non-JSON non-file multipart props need to be text/plain * refactor: Avoid breaking change Co-authored-by: Constantinos Symeonides <constantinos.symeonides@mindfoundry.ai>
- Loading branch information
Showing
26 changed files
with
750 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ecord/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Any, Dict, List, Type, TypeVar, Union | ||
|
||
import attr | ||
|
||
from ..types import UNSET, Unset | ||
|
||
T = TypeVar("T", bound="BodyUploadFileTestsUploadPostAdditionalProperty") | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class BodyUploadFileTestsUploadPostAdditionalProperty: | ||
""" """ | ||
|
||
foo: Union[Unset, str] = UNSET | ||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
foo = self.foo | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update({}) | ||
if foo is not UNSET: | ||
field_dict["foo"] = foo | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
d = src_dict.copy() | ||
foo = d.pop("foo", UNSET) | ||
|
||
body_upload_file_tests_upload_post_additional_property = cls( | ||
foo=foo, | ||
) | ||
|
||
body_upload_file_tests_upload_post_additional_property.additional_properties = d | ||
return body_upload_file_tests_upload_post_additional_property | ||
|
||
@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 |
54 changes: 54 additions & 0 deletions
54
...cord/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Any, Dict, List, Type, TypeVar, Union | ||
|
||
import attr | ||
|
||
from ..types import UNSET, Unset | ||
|
||
T = TypeVar("T", bound="BodyUploadFileTestsUploadPostSomeNullableObject") | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class BodyUploadFileTestsUploadPostSomeNullableObject: | ||
""" """ | ||
|
||
bar: Union[Unset, str] = UNSET | ||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
bar = self.bar | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update({}) | ||
if bar is not UNSET: | ||
field_dict["bar"] = bar | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
d = src_dict.copy() | ||
bar = d.pop("bar", UNSET) | ||
|
||
body_upload_file_tests_upload_post_some_nullable_object = cls( | ||
bar=bar, | ||
) | ||
|
||
body_upload_file_tests_upload_post_some_nullable_object.additional_properties = d | ||
return body_upload_file_tests_upload_post_some_nullable_object | ||
|
||
@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 |
Oops, something went wrong.