diff --git a/drf_spectacular/contrib/rest_framework_simplejwt.py b/drf_spectacular/contrib/rest_framework_simplejwt.py index 3decfdec..460d42b9 100644 --- a/drf_spectacular/contrib/rest_framework_simplejwt.py +++ b/drf_spectacular/contrib/rest_framework_simplejwt.py @@ -81,3 +81,7 @@ def get_security_definition(self, auto_schema): class SimpleJWTTokenUserScheme(SimpleJWTScheme): target_class = 'rest_framework_simplejwt.authentication.JWTTokenUserAuthentication' + + +class SimpleJWTStatelessUserScheme(SimpleJWTScheme): + target_class = "rest_framework_simplejwt.authentication.JWTStatelessUserAuthentication" diff --git a/tests/contrib/test_simplejwt.py b/tests/contrib/test_simplejwt.py index bb7b8ad2..690414c4 100644 --- a/tests/contrib/test_simplejwt.py +++ b/tests/contrib/test_simplejwt.py @@ -8,7 +8,7 @@ try: from rest_framework_simplejwt.authentication import ( - JWTAuthentication, JWTTokenUserAuthentication, + JWTAuthentication, JWTStatelessUserAuthentication, JWTTokenUserAuthentication, ) from rest_framework_simplejwt.views import ( TokenObtainPairView, TokenObtainSlidingView, TokenRefreshView, TokenVerifyView, @@ -34,8 +34,14 @@ class X2Viewset(mixins.ListModelMixin, viewsets.GenericViewSet): required_scopes = ['x:read', 'x:write'] +class X3Viewset(mixins.ListModelMixin, viewsets.GenericViewSet): + serializer_class = XSerializer + authentication_classes = [JWTStatelessUserAuthentication] + required_scopes = ['x:read', 'x:write'] + + @pytest.mark.contrib('rest_framework_simplejwt') -@pytest.mark.parametrize('view', [XViewset, X2Viewset]) +@pytest.mark.parametrize('view', [XViewset, X2Viewset, X3Viewset]) def test_simplejwt(no_warnings, view): router = routers.SimpleRouter() router.register('x', view, basename="x")