mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
improve tag generation from viewset name
This commit is contained in:
parent
44c1c25bde
commit
a5eec91196
|
@ -590,12 +590,14 @@ class AutoSchema(ViewInspector):
|
||||||
return self._tags
|
return self._tags
|
||||||
|
|
||||||
# Extract tag from viewset name
|
# Extract tag from viewset name
|
||||||
# UserViewSet tags = [User]
|
# UserView tags = [User]
|
||||||
# User tags = [User]
|
# User tags = [User]
|
||||||
if hasattr(self.view, 'action'):
|
if hasattr(self.view, 'action'):
|
||||||
name = self.view.__class__.__name__
|
name = self.view.__class__.__name__
|
||||||
if name.lower().endswith('viewset'):
|
if name.endswith('APIView') or name.endswith('ViewSet'):
|
||||||
name = name[:-7] # remove trailing `viewset` from name
|
name = name[:-7]
|
||||||
|
elif name.endswith('View'):
|
||||||
|
name = name[:-4]
|
||||||
return [name]
|
return [name]
|
||||||
|
|
||||||
# First element of a specific path could be valid tag. This is a fallback solution.
|
# First element of a specific path could be valid tag. This is a fallback solution.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user