Skip to content

Commit

Permalink
Allow Response objects with no schema
Browse files Browse the repository at this point in the history
Fixes #66.
  • Loading branch information
axnsan12 committed Feb 22, 2018
1 parent d507308 commit 64c280e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/drf_yasg/inspectors/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_response_schemas(self, response_serializers):
)
elif isinstance(serializer, openapi.Response):
response = serializer
if not isinstance(response.schema, openapi.Schema.OR_REF):
if hasattr(response, 'schema') and not isinstance(response.schema, openapi.Schema.OR_REF):
serializer = force_serializer_instance(response.schema)
response.schema = self.serializer_to_schema(serializer)
elif isinstance(serializer, openapi.Schema.OR_REF):
Expand Down
8 changes: 6 additions & 2 deletions testproj/snippets/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from djangorestframework_camel_case.parser import CamelCaseJSONParser
from djangorestframework_camel_case.render import CamelCaseJSONRenderer
from inflection import camelize
from rest_framework import generics
from rest_framework import generics, status
from rest_framework.parsers import FormParser

from drf_yasg import openapi
Expand Down Expand Up @@ -62,8 +62,12 @@ def patch(self, request, *args, **kwargs):
type=openapi.TYPE_INTEGER,
description="path parameter override",
required=True
),
], responses={
status.HTTP_204_NO_CONTENT: openapi.Response(
description="This should not crash"
)
])
})
def delete(self, request, *args, **kwargs):
"""delete method docstring"""
return super(SnippetDetail, self).patch(request, *args, **kwargs)
2 changes: 1 addition & 1 deletion tests/reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ paths:
type: integer
responses:
'204':
description: ''
description: This should not crash
tags:
- snippets
parameters:
Expand Down

0 comments on commit 64c280e

Please sign in to comment.