Ignore None when passed in as response override

Closes #148
This commit is contained in:
Cristi Vîjdea
2018-06-29 23:13:36 +03:00
parent 544d72db0a
commit 9fa4765121
4 changed files with 7 additions and 5 deletions
+2
View File
@@ -230,6 +230,8 @@ class SwaggerAutoSchema(ViewInspector):
response = openapi.Response(
description=serializer
)
elif not serializer:
continue
elif isinstance(serializer, openapi.Response):
response = serializer
if hasattr(response, 'schema') and not isinstance(response.schema, openapi.Schema.OR_REF):
+2
View File
@@ -76,6 +76,8 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
* if a plain string is given as value, a :class:`.Response` with no body and that string as its description
will be generated
* if ``None`` is given as a value, the response is ignored; this is mainly useful for disabling default
2xx responses, i.e. ``responses={200: None, 302: 'something'}``
* if a :class:`.Schema`, :class:`.SchemaRef` is given, a :class:`.Response` with the schema as its body and
an empty description will be generated
* a ``Serializer`` class or instance will be converted into a :class:`.Schema` and treated as above