Open DvaMishkiLapa opened 1 year ago
So far, nothing better than making peculiar hooks of the necessary Views does not come to mind. It works, but it doesn't seem to be the right approach to the situation.
# views.py
from trench.views.base import MFAMethodActivationView
from drf_spectacular.utils import extend_schema
class TOTPMethodActivationView(MFAMethodActivationView):
@extend_schema(
summary="TOTP MFA method activation",
description="Request a new TOTP activation and get an authentication code",
request=None,
responses={
200: TOTPMethodActivationSuccSerializer,
400: TrenchErrSerializer
}
)
def post(self, request, *args, **kwargs):
return super().post(request, method='app', *args, **kwargs)
# urls.py
urlpatterns = [
...
path('auth/app/activate/', TOTPMethodActivationView.as_view(), name='totp-activate'),
...
]
Running into the same issue I've found that spectacular provides the possibility to define extensions to provide metadata needed to generate correct schema for libraries not under your control.
There is also a page with extension blueprints which contain extensions already made for often used libraries. Unfortunately trench not being one of them. Tried searching on github also for anyone who might have done this work already, but to no avail.
I've seen a lot of references to drf-spectacular:
But, using the latest version of drf-spectacular in my project, in conjunction with django-trench, I get a lot of warnings about lack of serializers:
I see the needed changes in Swagger UI, but they are not fully customized - missing request bodies, any description. How much drf-spectacular support is there now? Are there any solutions to the problem I've encountered?
My approximate environment, to understand the situation: