File tree Expand file tree Collapse file tree 3 files changed +76
-18
lines changed Expand file tree Collapse file tree 3 files changed +76
-18
lines changed Original file line number Diff line number Diff line change @@ -106,9 +106,6 @@ def build_body_field(self) -> None:
106
106
and len (body_resolvers ) == 1
107
107
and not (
108
108
body_resolvers [0 ].model_field .field_info .embed # type: ignore[attr-defined]
109
- and isinstance (
110
- body_resolvers [0 ].model_field .field_info , params .BodyFieldInfo
111
- )
112
109
)
113
110
):
114
111
check_file_field (body_resolvers [0 ].model_field )
Original file line number Diff line number Diff line change 10
10
"content" : {
11
11
"multipart/form-data" : {
12
12
"schema" : {
13
- "title" : "Test" ,
14
- "type" : "string" ,
15
- "format" : "binary" ,
13
+ "title" : "Body" ,
14
+ "allOf" : [
15
+ {
16
+ "$ref" : "#/components/schemas/body_form_upload_single_case_1__post"
17
+ }
18
+ ],
16
19
"include_in_schema" : True ,
17
20
}
18
21
}
174
177
"content" : {
175
178
"multipart/form-data" : {
176
179
"schema" : {
177
- "title" : "Test1" ,
178
- "type" : "array" ,
179
- "items" : {
180
- "anyOf" : [
181
- {"type" : "string" , "format" : "binary" },
182
- {"type" : "string" },
183
- ]
184
- },
180
+ "title" : "Body" ,
181
+ "allOf" : [
182
+ {
183
+ "$ref" : "#/components/schemas/body_form_upload_multiple_case_1_multiple_post"
184
+ }
185
+ ],
185
186
"include_in_schema" : True ,
186
187
}
187
188
}
276
277
},
277
278
},
278
279
},
280
+ "body_form_upload_multiple_case_1_multiple_post" : {
281
+ "title" : "body_form_upload_multiple_case_1_multiple_post" ,
282
+ "required" : ["test1" ],
283
+ "type" : "object" ,
284
+ "properties" : {
285
+ "test1" : {
286
+ "title" : "Test1" ,
287
+ "type" : "array" ,
288
+ "items" : {
289
+ "anyOf" : [
290
+ {"type" : "string" , "format" : "binary" },
291
+ {"type" : "string" },
292
+ ]
293
+ },
294
+ "include_in_schema" : True ,
295
+ }
296
+ },
297
+ },
279
298
"body_form_upload_multiple_case_2_mixed_optional_post" : {
280
299
"title" : "body_form_upload_multiple_case_2_mixed_optional_post" ,
281
300
"type" : "object" ,
299
318
},
300
319
},
301
320
},
321
+ "body_form_upload_single_case_1__post" : {
322
+ "title" : "body_form_upload_single_case_1__post" ,
323
+ "required" : ["test" ],
324
+ "type" : "object" ,
325
+ "properties" : {
326
+ "test" : {
327
+ "title" : "Test" ,
328
+ "type" : "string" ,
329
+ "format" : "binary" ,
330
+ "include_in_schema" : True ,
331
+ }
332
+ },
333
+ },
302
334
"body_form_upload_single_case_2_mixed_post" : {
303
335
"title" : "body_form_upload_single_case_2_mixed_post" ,
304
336
"required" : ["test_alias" , "test2" ],
Original file line number Diff line number Diff line change @@ -93,15 +93,44 @@ def test_schema():
93
93
params = document ["paths" ]["/form-schema" ]["post" ]["requestBody" ]
94
94
assert params == {
95
95
"content" : {
96
- "application/x-www- form-urlencoded " : {
96
+ "application/form-data " : {
97
97
"schema" : {
98
- "allOf" : [{"$ref" : "#/components/schemas/Filter" }],
98
+ "allOf" : [
99
+ {
100
+ "$ref" : "#/components/schemas/body_form_params_schema_form_schema_post"
101
+ }
102
+ ],
99
103
"include_in_schema" : True ,
100
- "title" : "Will Not Work For Schema With Many Field " ,
104
+ "title" : "Body " ,
101
105
}
102
106
}
107
+ }
108
+ }
109
+ schema = document ["components" ]["schemas" ][
110
+ "body_form_params_schema_form_schema_post"
111
+ ]
112
+ assert schema == {
113
+ "title" : "body_form_params_schema_form_schema_post" ,
114
+ "type" : "object" ,
115
+ "properties" : {
116
+ "to" : {
117
+ "title" : "To" ,
118
+ "type" : "string" ,
119
+ "format" : "date-time" ,
120
+ "include_in_schema" : True ,
121
+ },
122
+ "from" : {
123
+ "title" : "From" ,
124
+ "type" : "string" ,
125
+ "format" : "date-time" ,
126
+ "include_in_schema" : True ,
127
+ },
128
+ "range" : {
129
+ "allOf" : [{"$ref" : "#/components/schemas/Range" }],
130
+ "default" : 20 ,
131
+ "include_in_schema" : True ,
132
+ },
103
133
},
104
- "required" : True ,
105
134
}
106
135
107
136
You can’t perform that action at this time.
0 commit comments