Skip to content

Commit

Permalink
Fixes OpenAPI schema for Content create operations
Browse files Browse the repository at this point in the history
The code[0] for special handling of FileFields when generating the OpenAPI schema was
introduced to work around a bug in drf-yasg[1]. This code was then ported when pulpcore
switched to using drf_spectacular for generating OpenAPI. This code is not needed. It
actually causes the OpenAPI schema for Content creation APIs to be different from all
other create operations.

[0] pulp@24b5071#diff-0535b5e0e76e73cdc44991f38a187114c123eb5ba125bda3015ca222a2b18088
[1] axnsan12/drf-yasg#386

closes pulp#2806
  • Loading branch information
dkliban committed Jun 6, 2022
1 parent ea3b9c4 commit c5c456a
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions pulpcore/openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,6 @@ def _get_serializer_name(self, serializer, direction):
name = name + "Response"
return name

def map_parsers(self):
"""
Get request parsers.
Handling cases with `FileField`.
"""
parsers = super().map_parsers()
serializer = force_instance(self.get_request_serializer())
for field_name, field in getattr(serializer, "fields", {}).items():
if isinstance(field, serializers.FileField) and self.method in ("PUT", "PATCH", "POST"):
return ["multipart/form-data", "application/x-www-form-urlencoded"]
return parsers

def _get_request_body(self):
"""Get request body."""
request_body = super()._get_request_body()
Expand Down

0 comments on commit c5c456a

Please sign in to comment.