安裝coreapi

pip install coreapi
image-20220317170252821.png

修改caseplatform\settings.py

  1. REST_FRAMEWORK = {
  2. # ...其余代码省略
  3. 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
  4. }

修改caseplatform\usls.py

  1. from django.contrib import admin
  2. from django.urls import path, include
  3. from rest_framework_jwt.views import obtain_jwt_token
  4. from rest_framework.documentation import include_docs_urls
  5. urlpatterns = [
  6. path('admin/', admin.site.urls),
  7. path('', include('project.urls')),
  8. path('login/', obtain_jwt_token),
  9. path('api/', include_docs_urls(title='接口文档')),
  10. ]

访问接口文档

浏览器访问http://127.0.0.1:8001/api/
image-20220317170958672.png

如果想要测试接口的话,直接点击Interact即可
image-20220317172311215.png

image-20220317172344312.png