I went through Django REST Swagger 2.1.2 documentation. When I tried with class based views, it was working fine.
But i did not find any reference on how to enable s
i am not fammiliar with swagger,but you may try to use the decorator in this way:
class TestView(View):
@api_view(['GET', 'POST'])
def get(self, request):
....
or
from django.utils.decorators import method_decorator
class TestView(View):
@method_decorator(api_view(['GET', 'POST'])
def get(self, request):
....
sorry, maybe i have misunderstood your question. according to the document, if you want to enable swagger in class based view. there is example:
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.schemas import SchemaGenerator
from rest_framework.views import APIView
from rest_framework_swagger import renderers
class SwaggerSchemaView(APIView):
permission_classes = [AllowAny]
renderer_classes = [
renderers.OpenAPIRenderer,
renderers.SwaggerUIRenderer
]
def get(self, request):
generator = SchemaGenerator()
schema = generator.get_schema(request=request)
return Response(schema)
restframework will use these two renderer_classes to render Json and UI.