-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyError: 'trace' #244
Comments
hi @ndrbrt, i'm a bit surprised how you got there. http verbs TRACE and OPTIONS are not explicitly supported. a quick test i did just ignored the |
Ok, I kinda figured out the problem. I have some urls which map to a view called Now, that view looks like this: from rest_framework.decorators import api_view
from django.http import Http404
from .constants import HTTP_METHODS
@api_view(HTTP_METHODS)
def not_found(request, *args, **kwargs):
raise Http404 And those """
HTTP Methods list, as reported on
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
"""
HTTP_METHODS = [
'GET',
'HEAD',
'POST',
'PUT',
'DELETE',
'CONNECT',
'OPTIONS',
'TRACE',
'PATCH'
] As I expected, after commenting the unsupported methods, it starts working. In the end, I should probably solve this by just rewrite that view as a class, but maybe this is an edge case that's worth covering? Thank you in advance. |
even though quite uncommon we should not run into these kind of issues but rather just ignore those endpoints. that fix should do it. |
can you check this works with new release |
I just tested it out and can confirm it's now working with |
According to https://swagger.io/specification/#path-item-object, all the http verbs are supported in the OpenAPI schema. Personally, i would really like to see the HEAD verb there. |
I came up with a test but since |
Right: What i am missing is the head method generated by openapi-generator, and i am wondering if the api spec would need to advertise that. |
well that is another good but orthogonal question but I would guess it needs to be included in the schema. some targets to openapi-generator might generate it in any case but I wouldn't bet on it. It's certainly in the realm of possible. from a schema perspective it makes sense to include it if desired, but as I mentioned DRF handles HEAD a bit different which makes this a non-trivial change to spectacular (given above requirements). |
Let me add HEAD specifically as a wish in a new issue then. |
My environment:
I got the following error:
The text was updated successfully, but these errors were encountered: