I've faced one issue connected with schema generation.
Case:
I want to release some common logic for some of my views, for instance: token check.
One of the way to do it without repetitions is just:
from rest_framework.permissions import BasePermission
from rest_framework.views import APIView
class SecretTokenPermission(BasePermission):
pass
class BaseInternalApiView(APIView):
permission_classes = [SecretTokenPermission]
But then when I use something like:
class AccountTopUpView(BaseInternalApiView):
def get(self, request):
pass
is_api_view check in rest_framework/schemas/openapi.py return False because AccountTopUpView is not a subclass of APIView:
def is_api_view(callback):
"""
Return `True` if the given view callback is a REST framework view/viewset.
"""
# Avoid import cycle on APIView
from rest_framework.views import APIView
cls = getattr(callback, 'cls', None)
return (cls is not None) and issubclass(cls, APIView)
I want to suggest this change: let's check the full path of inheritance.
Hi!
I've faced one issue connected with schema generation.
Case:
I want to release some common logic for some of my views, for instance: token check. One of the way to do it without repetitions is just:
But then when I use something like:
is_api_view check in rest_framework/schemas/openapi.py return False because AccountTopUpView is not a subclass of APIView:
I want to suggest this change: let's check the full path of inheritance.