REST framework可以自动帮助我们生成接口文档。

接口文档以网页的方式呈现。

自动接口文档能生成的是继承自APIView及其子类的视图。

1.1. 安装依赖

REST framewrok生成接口文档需要coreapi库的支持。

pip install coreapi

1.2. 设置接口文档访问路径

在总路由中添加接口文档路径。

文档路由对应的视图配置为 rest_framework.documentation.include_docs_urls

参数  title 为接口文档网站的标题。

from rest_framework.documentation import include_docs_urls

urlpatterns = [
    ...
    path('docs/', include_docs_urls(title='站点页面标题'))
]
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-09-21
  • 2021-09-25
  • 2022-12-23
相关资源
相似解决方案