美文网首页
REST的API-文档

REST的API-文档

作者: 錦魚 | 来源:发表于2019-11-18 14:09 被阅读0次
  • 我们需要api文档来叙述api的内容
  • 我们会经常做出改动
  • 我们需要一个api文档来帮助检测功能

coreapi

  • 好看的api文档
  • pip install coreapi

纲要文档
# urls.py
from rest_framework.schemas import get_schema_view
    
urlpattern = [
    url(r'^schema/', get_schema_view(title='文档-API'))
]
改进为:API文档
from rest_framework.documentation import include_docs_urls

urlpattren = [
    url(r'docs/', include_docs_urls(title='医院-API'))
]

Swagger

  • 多编程语言通用的API文档
  • pip install django-rest-swagger

# setting.py
INSTALLED_APPS = [
    ...
    'rest_framework_swagger'
]

# urls.py
from rest_framework_swagger.views import get_swagger_view
urlpatterns = [
    url(r'docs/', get_swagger_view(title='病人-API'))
]

相关文章

网友评论

      本文标题:REST的API-文档

      本文链接:https://www.haomeiwen.com/subject/rtbvictx.html