-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple JWT integration goes wrong. #232
Comments
Hi @dem214, djangorestframework-simplejwt has a weird way of constructing those serializers. this should solve it. |
Hello, Something like that fixes schema for class SimpleJWTTokenRefreshView(OpenApiViewExtension):
target_class = 'rest_framework_simplejwt.views.TokenRefreshView'
def view_replacement(self):
if getattr(settings, 'SIMPLE_JWT', {}).get('ROTATE_REFRESH_TOKENS', False):
class TokenRefreshResponseSerializer(serializers.Serializer):
access = serializers.CharField()
refresh = serializers.CharField()
else:
class TokenRefreshResponseSerializer(serializers.Serializer):
access = serializers.CharField()
class Fixed(self.target_class):
@extend_schema(responses=TokenRefreshResponseSerializer)
def post(self, request, *args, **kwargs):
pass # pragma: no cover
return Fixed @tfranzel By the way, thanks for maintaining such a great project! |
Nicely done |
hey @marcinjosinski, i missed that one too. slightly modified your proposal to target class TokenRefreshResponseSerializer(serializers.Serializer):
access = serializers.CharField() i think your proposal has a slight bug. as far as i understand, for this also fixes |
My proposal gives the same results because I override responses here only, but targeting the Serializer is a more elegant solution. I've just checked it and everything looks good. Thanks! |
Describe the bug

Generated schema shows wrong response schema of
rest_fremework_simplejwt.views.TokenObtainPairView()
To Reproduce
Add this to urls of new django project:
Check the schema.
Expected behavior
api/token/
view must response with schema like{"access":string,"refresh":string}
Versions
django==3.0.10
djangorestframework==3.12.1
djangorestframework-simplejwt==4.4.0
drf-spectacular==0.11.1
See also
Same problem can be with
from rest_framework_simplejwt.views.TokenRefreshView
The text was updated successfully, but these errors were encountered: