Allow Response objects with no schema

Fixes #66.
openapi3 1.4.2
Cristi Vîjdea 2018-02-22 03:45:03 +02:00
parent d5073081d9
commit 64c280e222
3 changed files with 8 additions and 4 deletions

View File

@ -221,7 +221,7 @@ class SwaggerAutoSchema(ViewInspector):
) )
elif isinstance(serializer, openapi.Response): elif isinstance(serializer, openapi.Response):
response = serializer 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) serializer = force_serializer_instance(response.schema)
response.schema = self.serializer_to_schema(serializer) response.schema = self.serializer_to_schema(serializer)
elif isinstance(serializer, openapi.Schema.OR_REF): elif isinstance(serializer, openapi.Schema.OR_REF):

View File

@ -1,7 +1,7 @@
from djangorestframework_camel_case.parser import CamelCaseJSONParser from djangorestframework_camel_case.parser import CamelCaseJSONParser
from djangorestframework_camel_case.render import CamelCaseJSONRenderer from djangorestframework_camel_case.render import CamelCaseJSONRenderer
from inflection import camelize from inflection import camelize
from rest_framework import generics from rest_framework import generics, status
from rest_framework.parsers import FormParser from rest_framework.parsers import FormParser
from drf_yasg import openapi from drf_yasg import openapi
@ -62,8 +62,12 @@ class SnippetDetail(generics.RetrieveUpdateDestroyAPIView):
type=openapi.TYPE_INTEGER, type=openapi.TYPE_INTEGER,
description="path parameter override", description="path parameter override",
required=True required=True
),
], responses={
status.HTTP_204_NO_CONTENT: openapi.Response(
description="This should not crash"
) )
]) })
def delete(self, request, *args, **kwargs): def delete(self, request, *args, **kwargs):
"""delete method docstring""" """delete method docstring"""
return super(SnippetDetail, self).patch(request, *args, **kwargs) return super(SnippetDetail, self).patch(request, *args, **kwargs)

View File

@ -330,7 +330,7 @@ paths:
type: integer type: integer
responses: responses:
'204': '204':
description: '' description: This should not crash
tags: tags:
- snippets - snippets
parameters: parameters: