Include .action attribute on viewsets when generating schemas (#4408)

This commit is contained in:
Tom Christie 2016-08-15 17:10:55 +01:00 committed by GitHub
parent 101fd29039
commit e3f8d06baf
2 changed files with 8 additions and 0 deletions

View File

@ -79,6 +79,13 @@ class SchemaGenerator(object):
view.kwargs = {}
view.format_kwarg = None
actions = getattr(callback, 'actions', None)
if actions is not None:
if method == 'OPTIONS':
view.action = 'metadata'
else:
view.action = actions.get(method.lower())
if request is not None:
view.request = clone_request(request, method)
try:

View File

@ -49,6 +49,7 @@ class ExampleViewSet(ModelViewSet):
def get_serializer(self, *args, **kwargs):
assert self.request
assert self.action
return super(ExampleViewSet, self).get_serializer(*args, **kwargs)