From 6942fa5dabe83793b9db19e86821c24438f22885 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 5 Aug 2015 13:59:55 +0100 Subject: [PATCH] Mask view docstring on 401 and 403 responses. Closes #3216. --- rest_framework/renderers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index bcc3302c1e..cb45252fdc 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -592,7 +592,9 @@ def __init__(self): def get_name(self, view): return view.get_view_name() - def get_description(self, view): + def get_description(self, view, status_code): + if status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN): + return '' return view.get_view_description(html=True) def get_breadcrumbs(self, request): @@ -631,7 +633,7 @@ def get_context(self, data, accepted_media_type, renderer_context): 'view': view, 'request': request, 'response': response, - 'description': self.get_description(view), + 'description': self.get_description(view, response.status_code), 'name': self.get_name(view), 'version': VERSION, 'paginator': paginator,