I used Django REST Swagger in my Django project. It is able to show all the URL with views which does not have
permission_classes = [IsAuthenticated]
. While the view with permission_classes = [IsAuthenticated]
is not shown in the list-api.
Here is an example:
class EquipmentCategoryViewSet(ResponseMixin, viewsets.ModelViewSet):
queryset = EquipmentCategory.objects.all()
serializer_class = EquipmentCategorySerializer
permission_classes = [IsAuthenticated]
if i remove permission_classes = [IsAuthenticated]
, it is shown in the swagger list-api.
I downgraded swagger to 2.1.2 and clicked on authorized and passed the token.
The strange thing is I have a prefix 'Token' in my value. When i login with Token<tokenvalue>
login fails. But when I pass <tokenvalue>
it gets authenticated but the views with isAuthenticated is not shown.
Please suggest what should be done to show views with isAuthenticated added.
In document API top right corner there is a option for authorise or to log in. Do provide valid token in it or login. This will list other endpoints.
Use swagger 2.1.2.
The latest django swagger version 2.2 has some issue with authorization. Refer: https://github.com/marcgibbons/django-rest-swagger/issues/762
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With