Skip to content

Commit 9d8dffc

Browse files
committed
test: Fix schema of new e2e test
1 parent 370c66b commit 9d8dffc

File tree

5 files changed

+144
-109
lines changed

5 files changed

+144
-109
lines changed

end_to_end_tests/baseline_openapi_3.0.json

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,57 @@
8787
}
8888
}
8989
},
90+
"/bodies/multipart/multiple-files-in-object": {
91+
"post": {
92+
"tags": [
93+
"tests"
94+
],
95+
"summary": "Array of files in object",
96+
"description": "Upload an array of files as part of an object",
97+
"operationId": "upload_array_of_files_in_object_tests_upload_post",
98+
"parameters": [],
99+
"requestBody": {
100+
"content": {
101+
"multipart/form-data": {
102+
"schema": {
103+
"type" : "object",
104+
"properties" : {
105+
"files": {
106+
"type": "array",
107+
"items": {
108+
"type": "string",
109+
"description": "attachments content",
110+
"format": "binary"
111+
}
112+
}
113+
}
114+
}
115+
}
116+
},
117+
"required": true
118+
},
119+
"responses": {
120+
"200": {
121+
"description": "Successful Response",
122+
"content": {
123+
"application/json": {
124+
"schema": {}
125+
}
126+
}
127+
},
128+
"422": {
129+
"description": "Validation Error",
130+
"content": {
131+
"application/json": {
132+
"schema": {
133+
"$ref": "#/components/schemas/HTTPValidationError"
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}
140+
},
90141
"/tests/": {
91142
"get": {
92143
"tags": [
@@ -450,55 +501,6 @@
450501
}
451502
}
452503
},
453-
"/tests/upload/multiple-files-in-object": {
454-
"post": {
455-
"tags": [
456-
"tests"
457-
],
458-
"summary": "Array of files in object",
459-
"description": "Upload an array of files as part of an object",
460-
"operationId": "upload_array_of_files_in_object_tests_upload_post",
461-
"parameters": [],
462-
"requestBody": {
463-
"content": {
464-
"multipart/form-data": {
465-
"schema": {
466-
"type" : "object",
467-
"files" : {
468-
"type" : "array",
469-
"items" : {
470-
"type" : "string",
471-
"description" : "attachments content",
472-
"format" : "binary"
473-
}
474-
}
475-
}
476-
}
477-
},
478-
"required": true
479-
},
480-
"responses": {
481-
"200": {
482-
"description": "Successful Response",
483-
"content": {
484-
"application/json": {
485-
"schema": {}
486-
}
487-
}
488-
},
489-
"422": {
490-
"description": "Validation Error",
491-
"content": {
492-
"application/json": {
493-
"schema": {
494-
"$ref": "#/components/schemas/HTTPValidationError"
495-
}
496-
}
497-
}
498-
}
499-
}
500-
}
501-
},
502504
"/tests/json_body": {
503505
"post": {
504506
"tags": [

end_to_end_tests/baseline_openapi_3.1.yaml

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,57 @@ info:
8383
}
8484
}
8585
},
86+
"/bodies/multipart/multiple-files-in-object": {
87+
"post": {
88+
"tags": [
89+
"tests"
90+
],
91+
"summary": "Array of files in object",
92+
"description": "Upload an array of files as part of an object",
93+
"operationId": "upload_array_of_files_in_object_tests_upload_post",
94+
"parameters": [ ],
95+
"requestBody": {
96+
"content": {
97+
"multipart/form-data": {
98+
"schema": {
99+
"type": "object",
100+
"properties": {
101+
"files": {
102+
"type": "array",
103+
"items": {
104+
"type": "string",
105+
"description": "attachments content",
106+
"format": "binary"
107+
}
108+
}
109+
}
110+
}
111+
}
112+
},
113+
"required": true
114+
},
115+
"responses": {
116+
"200": {
117+
"description": "Successful Response",
118+
"content": {
119+
"application/json": {
120+
"schema": { }
121+
}
122+
}
123+
},
124+
"422": {
125+
"description": "Validation Error",
126+
"content": {
127+
"application/json": {
128+
"schema": {
129+
"$ref": "#/components/schemas/HTTPValidationError"
130+
}
131+
}
132+
}
133+
}
134+
}
135+
}
136+
},
86137
"/tests/": {
87138
"get": {
88139
"tags": [
@@ -446,55 +497,6 @@ info:
446497
}
447498
}
448499
},
449-
"/tests/upload/multiple-files-in-object": {
450-
"post": {
451-
"tags": [
452-
"tests"
453-
],
454-
"summary": "Array of files in object",
455-
"description": "Upload an array of files as part of an object",
456-
"operationId": "upload_array_of_files_in_object_tests_upload_post",
457-
"parameters": [ ],
458-
"requestBody": {
459-
"content": {
460-
"multipart/form-data": {
461-
"schema": {
462-
"type": "object",
463-
"files": {
464-
"type": "array",
465-
"items": {
466-
"type": "string",
467-
"description": "attachments content",
468-
"format": "binary"
469-
}
470-
}
471-
}
472-
}
473-
},
474-
"required": true
475-
},
476-
"responses": {
477-
"200": {
478-
"description": "Successful Response",
479-
"content": {
480-
"application/json": {
481-
"schema": { }
482-
}
483-
}
484-
},
485-
"422": {
486-
"description": "Validation Error",
487-
"content": {
488-
"application/json": {
489-
"schema": {
490-
"$ref": "#/components/schemas/HTTPValidationError"
491-
}
492-
}
493-
}
494-
}
495-
}
496-
}
497-
},
498500
"/tests/json_body": {
499501
"post": {
500502
"tags": [

end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/tests/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727

2828

2929
class TestsEndpoints:
30+
@classmethod
31+
def upload_array_of_files_in_object_tests_upload_post(cls) -> types.ModuleType:
32+
"""
33+
Upload an array of files as part of an object
34+
"""
35+
return upload_array_of_files_in_object_tests_upload_post
36+
3037
@classmethod
3138
def get_user_list(cls) -> types.ModuleType:
3239
"""
@@ -90,13 +97,6 @@ def upload_multiple_files_tests_upload_post(cls) -> types.ModuleType:
9097
"""
9198
return upload_multiple_files_tests_upload_post
9299

93-
@classmethod
94-
def upload_array_of_files_in_object_tests_upload_post(cls) -> types.ModuleType:
95-
"""
96-
Upload an array of files as part of an object
97-
"""
98-
return upload_array_of_files_in_object_tests_upload_post
99-
100100
@classmethod
101101
def json_body_tests_json_body_post(cls) -> types.ModuleType:
102102
"""

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_array_of_files_in_object_tests_upload_post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _get_kwargs(
2020

2121
_kwargs: Dict[str, Any] = {
2222
"method": "post",
23-
"url": "/tests/upload/multiple-files-in-object",
23+
"url": "/bodies/multipart/multiple-files-in-object",
2424
}
2525

2626
_body = body.to_multipart()

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,47 @@
1-
from typing import Any, Dict, List, Tuple, Type, TypeVar
1+
from io import BytesIO
2+
from typing import Any, Dict, List, Tuple, Type, TypeVar, Union
23

34
from attrs import define as _attrs_define
45
from attrs import field as _attrs_field
56

7+
from ..types import UNSET, File, FileJsonType, Unset
8+
69
T = TypeVar("T", bound="UploadArrayOfFilesInObjectTestsUploadPostBody")
710

811

912
@_attrs_define
1013
class UploadArrayOfFilesInObjectTestsUploadPostBody:
11-
""" """
14+
"""
15+
Attributes:
16+
files (Union[Unset, List[File]]):
17+
"""
1218

19+
files: Union[Unset, List[File]] = UNSET
1320
additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
1421

1522
def to_dict(self) -> Dict[str, Any]:
23+
files: Union[Unset, List[FileJsonType]] = UNSET
24+
if not isinstance(self.files, Unset):
25+
files = []
26+
for files_item_data in self.files:
27+
files_item = files_item_data.to_tuple()
28+
29+
files.append(files_item)
30+
1631
field_dict: Dict[str, Any] = {}
1732
field_dict.update(self.additional_properties)
33+
field_dict.update({})
34+
if files is not UNSET:
35+
field_dict["files"] = files
1836

1937
return field_dict
2038

2139
def to_multipart(self) -> List[Tuple[str, Any]]:
2240
field_list: List[Tuple[str, Any]] = []
41+
for cont in self.files or []:
42+
files_item = cont.to_tuple()
43+
44+
field_list.append(("files", files_item))
2345

2446
field_dict: Dict[str, Any] = {}
2547
field_dict.update(
@@ -33,7 +55,16 @@ def to_multipart(self) -> List[Tuple[str, Any]]:
3355
@classmethod
3456
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
3557
d = src_dict.copy()
36-
upload_array_of_files_in_object_tests_upload_post_body = cls()
58+
files = []
59+
_files = d.pop("files", UNSET)
60+
for files_item_data in _files or []:
61+
files_item = File(payload=BytesIO(files_item_data))
62+
63+
files.append(files_item)
64+
65+
upload_array_of_files_in_object_tests_upload_post_body = cls(
66+
files=files,
67+
)
3768

3869
upload_array_of_files_in_object_tests_upload_post_body.additional_properties = d
3970
return upload_array_of_files_in_object_tests_upload_post_body

0 commit comments

Comments
 (0)