简体   繁体   中英

Am using drf-spectacular for my Django rest api documentation, how to override our own endpoint

In below code am not able to generate schema for 2 endpoints admin/ and payslip/

urlpatterns = [ # YOUR PATTERNS path('admin/', admin.site.urls),, path('payslip/',include('payslip.urls')) path('api/schema/', SpectacularAPIView.as_view(), name='schema'), # Optional UI: path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'), ]

The Django admin is not built from REST API endpoints. The admin is made of a lot of regular Django templated html views. Views discovered by drf-spectacular must be derived from either APIView or GenericAPIView in one way or another. These are the fundamental base classes of rest_framework .

Can't really attest to what payslip is made of but the same rules apply there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM