You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug, or if I'm just not reading the docs correctly:
I have a view that returns a '204 No Content' status, with a header that returns some relevant information, and no response body. I want to correctly represent this in my API documentation, so I'm doing something like this:
classMyView(APIView):
@swagger_auto_schema(responses={"204": openapi.Response(description="Your request was accepted, perform status queries using the value of the X-Query-ID header for updates",headers={"X-Query-ID": {"description": "The ID of the accepted query","type": openapi.TYPE_STRING } } ) } )defpost(self, request, ...):
However this fails with the following trace:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/drf_yasg/openapi.py", line 99, in __getattr__
return self[make_swagger_name(item)]
KeyError: 'schema'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 494, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 454, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/views.py", line 88, in get
schema = generator.get_schema(request, self.public)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 203, in get_schema
paths, prefix = self.get_paths(endpoints, components, request, public)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 317, in get_paths
operations[method.lower()] = self.get_operation(view, path, prefix, method, components, request)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 357, in get_operation
operation = view_inspector.get_operation(operation_keys)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/inspectors/view.py", line 38, in get_operation
responses = self.get_responses()
File "/usr/local/lib/python3.6/site-packages/drf_yasg/inspectors/view.py", line 161, in get_responses
responses=self.get_response_schemas(response_serializers)
File "/src/lib/ucee-django-utils/ucee_django_utils/schema.py", line 25, in get_response_schemas
resp_schemas = super().get_response_schemas(response_serializers)
File "/usr/local/lib/python3.6/site-packages/drf_yasg/inspectors/view.py", line 224, in get_response_schemas
if not isinstance(response.schema, openapi.Schema.OR_REF):
File "/usr/local/lib/python3.6/site-packages/drf_yasg/openapi.py", line 102, in __getattr__
raise AttributeError("object of class " + type(self).__name__ + " has no attribute " + item)
AttributeError: object of class Response has no attribute schema
[22/Feb/2018 13:45:45] "GET /_internal/auth/schema HTTP/1.0" 500 17194
It works if I set the schema kwarg on the Response (either with a serializer or a manually created Schema instance; setting it to no_body doesn't work). As far as I can tell I should be able to specify a Response without a Schema (I can if I set the value of the responses dict to a string)?
The text was updated successfully, but these errors were encountered:
Not sure if this is a bug, or if I'm just not reading the docs correctly:
I have a view that returns a '204 No Content' status, with a header that returns some relevant information, and no response body. I want to correctly represent this in my API documentation, so I'm doing something like this:
However this fails with the following trace:
It works if I set the schema kwarg on the Response (either with a serializer or a manually created Schema instance; setting it to
no_body
doesn't work). As far as I can tell I should be able to specify a Response without a Schema (I can if I set the value of the responses dict to a string)?The text was updated successfully, but these errors were encountered: