Skip to content

Commit

Permalink
Only uses multipart when dealing with file fields
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed May 12, 2020
1 parent 8f236ef commit 496c65a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/6702.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only uses multipart OpenAPI Schema when dealing with `file` fields
9 changes: 5 additions & 4 deletions pulpcore/app/openapigenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,17 @@ def get_operation(self, operation_keys):
consumes = self.get_consumes()
produces = self.get_produces()

body = self.get_request_body_parameters(consumes)

multipart = ["multipart/form-data", "application/x-www-form-urlencoded"]
if self.method != "GET":
request_params = self.get_request_body_parameters(multipart)
type_list = [param["type"] for param in request_params if param]
if "file" in type_list:
type_list = [param["type"] for param in body if param]
if "file" in type_list and consumes != multipart:
# automatically set the media type to form data if there's a file
# needed due to https://github.com/axnsan12/drf-yasg/issues/386
consumes = multipart
body = self.get_request_body_parameters(consumes)

body = self.get_request_body_parameters(consumes)
query = self.get_query_parameters()
if self.method == "GET":
fields_paramenter = Parameter(
Expand Down

0 comments on commit 496c65a

Please sign in to comment.