Updated to work with ViewSets

This commit is contained in:
vkylamba 2017-12-27 12:09:18 +05:30
parent 5fc35eb7eb
commit 76c5338930

View File

@ -291,15 +291,17 @@ class AutoSchema(ViewInspector):
request body input, as determined by the serializer class.
"""
view = self.view
if method not in ('PUT', 'PATCH', 'POST'):
return []
if not hasattr(view, 'get_serializer'):
if not hasattr(view, 'get_serializer') and not hasattr(view, 'serializer_class'):
return []
try:
if hasattr(view, 'get_serializer'):
serializer = view.get_serializer()
elif hasattr(view, 'serializer_class'):
serializer = view.serializer_class()
except exceptions.APIException:
serializer = None
warnings.warn('{}.get_serializer() raised an exception during '