parent
544d72db0a
commit
9fa4765121
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class TodoRecursiveView(viewsets.ModelViewSet):
|
|||
def create(self, request, *args, **kwargs):
|
||||
return super(TodoRecursiveView, self).create(request, *args, **kwargs)
|
||||
|
||||
@swagger_auto_schema(responses={200: TodoRecursiveSerializer})
|
||||
@swagger_auto_schema(responses={200: None, 302: 'Redirect somewhere'})
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
return super(TodoRecursiveView, self).retrieve(request, *args, **kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -560,10 +560,8 @@ paths:
|
|||
description: ''
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
schema:
|
||||
$ref: '#/definitions/TodoRecursive'
|
||||
'302':
|
||||
description: Redirect somewhere
|
||||
tags:
|
||||
- todo
|
||||
put:
|
||||
|
|
|
|||
Loading…
Reference in New Issue