diff --git a/rest_framework/schemas/views.py b/rest_framework/schemas/views.py index 845b68ea6..0610a0755 100644 --- a/rest_framework/schemas/views.py +++ b/rest_framework/schemas/views.py @@ -31,3 +31,10 @@ class SchemaView(APIView): if schema is None: raise exceptions.PermissionDenied() return Response(schema) + + def handle_exception(self, exc): + if isinstance(exc, (exceptions.NotAuthenticated, + exceptions.AuthenticationFailed)): + self.request.accepted_renderer = renderers.JSONRenderer() + + return super(SchemaView, self).handle_exception(exc)