-
Notifications
You must be signed in to change notification settings - Fork 602
Django Swagger shown HTTP Error 500 and not processed HTML code when accessing without logged in user #486
Comments
@civantos Could you provide the rendered error message? (can do so from the network tab). I am guessing that if this only happens when the |
|
I have the same problem, my stack:
as a workaround, I required user to log in, before access docs. |
Workaround works for me too, but there is still a warning about future function deprecations that may be related to this issue shown in my development server that I'm going to paste here so You can check: /home/civan/tuvika/startup/local/lib/python2.7/site-packages/rest_framework_swagger/renderers.py:37: RemovedInDjango110Warning: render() must be called with a dict, not a RequestContext. /usr/lib/python2.7/importlib/init.py:37: RemovedInDjango110Warning: django.core.context_processors is deprecated in favor of django.template.context_processors. |
I also got this and found a better solution (I think). The workaround you suggest to force login does not help our case, so I went into some debugging. Solved it by adding a permission_classes decorator. Might help for you. The code:
|
Apparently the difference is how the schema gets generated. Openapi gets generated as whole specification for every resources in the router. The error is thrown by the render that tries to dump a scheme for the whole router. Instead it gets serialized object as data param. Correct way is to put schema-generation view as a separated url rule
|
I went with the solution proposed by @bschellekens and that remove that issue, but still I'm having this one: object has no attribute 'request' . |
That's addressed here encode/django-rest-framework#4383 - new version 3.4.4 is due tomorrow. (Fri 12th Aug, 2016) |
Awesome @tomchristie thanks! |
Yep, confirming this can be closed with DRF 3.4.4 |
👍 great news, thanks for the update! |
Hey guys, whatever I do, still I'm having the same problem that Javier Civantos has showed in his First screenshot. Below is my error. would appreciate any help/suggestions-- 18/Aug/2016 20:57:33] "GET /swagger/ HTTP/1.1" 403 3924 |
@karingula Better exception handling is coming in 2.0.5 (#523). Hoping to release this weekend. |
django-rest-swagger==2.0.1
djangorestframework==3.4.0
-- urls.py --
-- views.py --
-- development server petitions log --
[19/Jul/2016 09:36:00] "GET /documentacion/?format=openapi HTTP/1.1" 500 83970
Now if I launch my project and type http://ip:port/documentacion/ in my browser I get an HTTP error 500 and display raw HTML content inside my Swagger view. The problem disappears when I use a logged in user. Anyway when l use a logged in user I still can see and endpoint with the same name that my scheme creator function 'esquema_doc_api' and returns HTML when I fire the GET method on it. I'm not pretty sure if it's supposed to be the standard behaviour.
I'll attach some screenshot with the problem.
Regards,
Javier Civantos
The text was updated successfully, but these errors were encountered: