简体   繁体   English

我正在为我的 Django rest api 文档使用 drf-spectacular,如何覆盖我们自己的端点

[英]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/在下面的代码中,我无法为 2 个端点 admin/ 和 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. Django 管理员不是从 REST API 端点构建的。 The admin is made of a lot of regular Django templated html views.管理员由许多常规的 Django 模板化 html 视图组成。 Views discovered by drf-spectacular must be derived from either APIView or GenericAPIView in one way or another. drf-spectacular发现的视图必须以一种或另一种方式从APIViewGenericAPIView派生。 These are the fundamental base classes of rest_framework .这些是rest_framework的基本基类。

Can't really attest to what payslip is made of but the same rules apply there.无法真正证明payslip是由什么组成的,但同样的规则适用于那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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