@@ -271,19 +271,20 @@ def parameters(operation):
271271 yield content ["name" ], content
272272
273273 if "requestBody" in operation :
274- if "multipart/form-data" in operation ["requestBody" ]["content" ]:
275- parent = operation ["requestBody" ]["content" ]["multipart/form-data" ]["schema" ]
276- for name , schema in parent ["properties" ].items ():
277- yield name , {
278- "in" : "form" ,
279- "schema" : schema ,
280- "name" : name ,
281- "description" : schema .get ("description" ),
282- "required" : name in parent .get ("required" , []),
283- }
284- else :
285- name = operation .get ("x-codegen-request-body-name" , "body" )
286- yield name , operation ["requestBody" ]
274+ for content_type in operation ["requestBody" ]["content" ]:
275+ if content_type == "multipart/form-data" :
276+ parent = operation ["requestBody" ]["content" ]["multipart/form-data" ]["schema" ]
277+ for name , schema in parent ["properties" ].items ():
278+ yield name , {
279+ "in" : "form" ,
280+ "schema" : schema ,
281+ "name" : name ,
282+ "description" : schema .get ("description" ),
283+ "required" : name in parent .get ("required" , []),
284+ }
285+ else :
286+ name = operation .get ("x-codegen-request-body-name" , "body" )
287+ yield name , operation ["requestBody" ]
287288
288289 for content in operation .get ("parameters" , []):
289290 if "schema" in content and not content .get ("required" ):
@@ -302,6 +303,14 @@ def form_parameter(operation):
302303 }
303304
304305
306+ def need_body_parameter (operation ):
307+ if "requestBody" in operation :
308+ for content_type in operation ["requestBody" ]["content" ]:
309+ if content_type != "multipart/form-data" :
310+ return True
311+ return False
312+
313+
305314def parameter_schema (parameter ):
306315 if "schema" in parameter :
307316 return parameter ["schema" ]
0 commit comments