Skip to content

Commit 14a9161

Browse files
author
Constantinos Symeonides
committed
feat: Support non-file fields in Multipart requests
1 parent 339fce7 commit 14a9161

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

end_to_end_tests/golden-record-custom/custom_e2e/models/body_upload_file_tests_upload_post.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from io import BytesIO
2-
from typing import Any, Dict, Type, TypeVar
2+
from typing import Any, Dict, Type, TypeVar, Union
33

44
import attr
55

6-
from ..types import File
6+
from ..types import UNSET, File, Unset
77

88
T = TypeVar("T", bound="BodyUploadFileTestsUploadPost")
99

@@ -13,16 +13,21 @@ class BodyUploadFileTestsUploadPost:
1313
""" """
1414

1515
some_file: File
16+
some_string: Union[Unset, str] = "some_default_string"
1617

1718
def to_dict(self) -> Dict[str, Any]:
1819
some_file = self.some_file.to_tuple()
1920

21+
some_string = self.some_string
22+
2023
field_dict: Dict[str, Any] = {}
2124
field_dict.update(
2225
{
2326
"some_file": some_file,
2427
}
2528
)
29+
if some_string is not UNSET:
30+
field_dict["some_string"] = some_string
2631

2732
return field_dict
2833

@@ -31,8 +36,11 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
3136
d = src_dict.copy()
3237
some_file = File(payload=BytesIO(d.pop("some_file")))
3338

39+
some_string = d.pop("some_string", UNSET)
40+
3441
body_upload_file_tests_upload_post = cls(
3542
some_file=some_file,
43+
some_string=some_string,
3644
)
3745

3846
return body_upload_file_tests_upload_post

end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from io import BytesIO
2-
from typing import Any, Dict, Type, TypeVar
2+
from typing import Any, Dict, Type, TypeVar, Union
33

44
import attr
55

6-
from ..types import File
6+
from ..types import UNSET, File, Unset
77

88
T = TypeVar("T", bound="BodyUploadFileTestsUploadPost")
99

@@ -13,16 +13,21 @@ class BodyUploadFileTestsUploadPost:
1313
""" """
1414

1515
some_file: File
16+
some_string: Union[Unset, str] = "some_default_string"
1617

1718
def to_dict(self) -> Dict[str, Any]:
1819
some_file = self.some_file.to_tuple()
1920

21+
some_string = self.some_string
22+
2023
field_dict: Dict[str, Any] = {}
2124
field_dict.update(
2225
{
2326
"some_file": some_file,
2427
}
2528
)
29+
if some_string is not UNSET:
30+
field_dict["some_string"] = some_string
2631

2732
return field_dict
2833

@@ -31,8 +36,11 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
3136
d = src_dict.copy()
3237
some_file = File(payload=BytesIO(d.pop("some_file")))
3338

39+
some_string = d.pop("some_string", UNSET)
40+
3441
body_upload_file_tests_upload_post = cls(
3542
some_file=some_file,
43+
some_string=some_string,
3644
)
3745

3846
return body_upload_file_tests_upload_post

end_to_end_tests/openapi.json

+5
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,11 @@
923923
"title": "Some File",
924924
"type": "string",
925925
"format": "binary"
926+
},
927+
"some_string": {
928+
"title": "Some String",
929+
"type": "string",
930+
"default": "some_default_string"
926931
}
927932
},
928933
"additionalProperties": false

0 commit comments

Comments
 (0)