From f276c48d6302876ab697090fbdf9531737d76f5f Mon Sep 17 00:00:00 2001 From: Giancarlo Rocha Date: Wed, 24 Oct 2018 18:31:37 -0300 Subject: [PATCH] fix: Changes renderer on auth problems --- rest_framework/schemas/views.py | 7 +++++++ 1 file changed, 7 insertions(+) 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)