Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django rest swagger unable to read api

I have set up the url as this in urls.py

url(r'^', include('rest_framework_swagger.urls', namespace='swagger')),

For the reason I do not understand, after the swagger API UI load from localhost:8000. None of the API can be expand with this error:

Unable to read api 'user' from path http://localhost:8000/api-docs/api/v1/user

I thought it is the issue with the api-docs in the url but after remove that and re-fetch again. I get these:

fetching resource list: http://localhost:8000/ 

Which I got no response after this after, or I get this if I add /api/v1 to the url

403 : undefined http://localhost:8000/api/v1

This is what I have in the settings.py for 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
}

Anyone know what I did wrong here? Any help would be appreciated! Thanks.

like image 524
Souloikj Avatar asked Nov 11 '22 03:11

Souloikj


1 Answers

Similarly to @SubodhNijsure, I had runtime errors for the endpoint in question. Trying a URL with the /api-docs/ prefix seems to be Swagger's way of failing when its JSON call for the endpoint information fails.

Solution: fix my runtime errors.

like image 58
calebds Avatar answered Jan 04 '23 02:01

calebds