django休息昂首阔步无法读懂api

Sou*_*ikj 5 swagger django-rest-framework

我在urls.py中设置了url

url(r'^', include('rest_framework_swagger.urls', namespace='swagger')),
Run Code Online (Sandbox Code Playgroud)

由于我不理解的原因,在从localhost:8000加载swigger API UI之后.没有API可以使用此错误进行扩展:

Unable to read api 'user' from path http://localhost:8000/api-docs/api/v1/user
Run Code Online (Sandbox Code Playgroud)

我认为这是url中的api-docs的问题,但删除后再重新获取.我得到这些:

fetching resource list: http://localhost:8000/ 
Run Code Online (Sandbox Code Playgroud)

在此之后我没有得到任何回复,或者如果我将/ api/v1添加到网址,我得到了这个回复

403 : undefined http://localhost:8000/api/v1
Run Code Online (Sandbox Code Playgroud)

这就是我在settings.py中的swagger:

SWAGGER_SETTINGS = {
    "exclude_namespaces": [], # List URL namespaces to ignore
    "api_version": 'alpha 1.0', # API's version
    "api_path": "/", # the path to API (it could not be a root level)
    "enabled_methods" : [ # method to enable in Swagger UI
        'get',
        'post',
        'delete'
    ],
    "api_key": '', # An API key
    "is_authentcated": False, # Set to True to enforce user authentication,
    "is_superuser": False, # Set to True to enforce admin only access
}
Run Code Online (Sandbox Code Playgroud)

谁知道我在这里做错了什么?任何帮助,将不胜感激!谢谢.

pai*_*lee 1

与@SubodhNijsure 类似,我遇到了相关端点的运行时错误。/api-docs/当对端点信息的 JSON 调用失败时,尝试使用带有前缀的 URL似乎是 Swagger 失败的方式。

解决方案:修复我的运行时错误。