django-rest-swagger 没有将 Markdown 文档字符串解析/翻译成 HTML 代码

标签 django markdown django-rest-framework api-doc

到目前为止我知道django-rest-swagger从 v0.1.10 开始支持 Markdown 语法中的文档字符串。但是当我尝试查看文档时,它显示为纯文本,而不是将其解析并转换为 HTML 代码。

enter image description here

我正在使用:

Django==1.5
Markdown==2.3.1
djangorestframework==2.3.10
django-rest-swagger==0.1.11

SWAGGER_SETTINGS = {
    "exclude_namespaces": [], # List URL namespaces to ignore
    "api_version": '0.1',  # Specify your API's version
    "api_path": "",  # Specify the path to your API not a root level
    "enabled_methods": [  # Specify which methods to enable in Swagger UI
        'get',
        'post',
        'put',
        'patch',
        'delete'
    ],
    "api_key": '', # An API key
    "is_authenticated": True,  # Set to True to enforce user authentication,
    "is_superuser": False,  # Set to True to enforce admin only access
}

API 示例代码基于功能的 View :

@api_view(['POST'])
def dummy(request):
    '''
    Lorem ipsum `dolor` sit amet, consectetur adipiscing elit. Etiam sodales lacus at _nulla_ fringilla fringilla. 

    ### Consectetur adipiscing:

       * __dummy_var__: Nunc ut erat justo. Duis turpis augue, posuere a ornare sed,
       * another: Vestibulum suscipit congue neque sed faucibus.
       * `code`: Cras sit amet ullamcorper ipsum.
    '''
    pass

当直接浏览 API 时,描述会被正确翻译/呈现。

enter image description here

我错过了什么吗?

最佳答案

从 v0.2.0 版本开始,markdown 在 django-rest-swagger 中可用!

只需要显式安装 markdown 包(不会自动安装):

pip install markdown

关于django-rest-swagger 没有将 Markdown 文档字符串解析/翻译成 HTML 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20938105/

相关文章:

python - 在 Django 中保存对象时使用变量

Flutter:如何在showDialog中使用Markdown?

reactjs - React Quill 句柄状态更改名称属性未定义

python-3.x - Djoser 使用模板覆盖激活电子邮件

python - 从 Django 的一页获取选定单选按钮的值

python - django-admin:如何在保存一个对象后重定向到 URL?

R Markdown 错误: can't produce HTML file

R Markdown 找不到文件但执行 block 有效

django - 为什么 drf-extensions CacheResponseMixin 不缓存?

python - 同时使用两个注释表达式时出现错误结果