Skip to content

Commit

Permalink
factor out serializer name estimation for easier modification #976
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Jul 9, 2023
1 parent 31665a3 commit 1a9be59
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drf_spectacular/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,9 @@ def _get_response_headers_for_code(self, status_code, direction='response') -> d

return result

def get_serializer_name(self, serializer, direction):
return serializer.__class__.__name__

def _get_serializer_name(self, serializer, direction, bypass_extensions=False):
serializer_extension = OpenApiSerializerExtension.get_match(serializer)
if serializer_extension and not bypass_extensions:
Expand All @@ -1538,7 +1541,7 @@ def _get_serializer_name(self, serializer, direction, bypass_extensions=False):
elif is_list_serializer(serializer):
return self._get_serializer_name(serializer.child, direction)
else:
name = serializer.__class__.__name__
name = self.get_serializer_name(serializer, direction)

if name.endswith('Serializer'):
name = name[:-10]
Expand Down

0 comments on commit 1a9be59

Please sign in to comment.