API生成文档

安装 

 

pip install django-coreapi
pip install pyyaml
  1. Schema

    # settings.py
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',

    # 总urls.py
    from rest_framework.schemas import get_schema_view
    schema_view = get_schema_view(title="北网在线 API文档",description="所有API文档")
    path('schema/',schema_view),
    
    
  2. coreapi

    # settings
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',

    # 总urls.py
    from rest_framework.documentation import include_docs_urls
    path('docs/',include_docs_urls(title="北网在线",description="所有API文档"))
    
    
  3. openapi

    # settings.py
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',


    from rest_framework.schemas import get_schema_view

    path('openapi', get_schema_view(
           title="Your Project",
           description="API for all things …"
       ), name='openapi-schema'),
    
    
原文地址:https://www.cnblogs.com/gyang/p/14043363.html