From 41b1ca44837abbac992d963c39b9b215a14390aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristi=20V=C3=AEjdea?= Date: Mon, 10 Sep 2018 00:02:23 +0300 Subject: [PATCH] Do not bail on response when request body is formData --- .idea/drf-yasg.iml | 4 ++++ src/drf_yasg/inspectors/view.py | 2 -- testproj/users/views.py | 2 +- tests/reference.yaml | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.idea/drf-yasg.iml b/.idea/drf-yasg.iml index 599fc6e..b236c83 100644 --- a/.idea/drf-yasg.iml +++ b/.idea/drf-yasg.iml @@ -16,7 +16,11 @@ + + + + diff --git a/src/drf_yasg/inspectors/view.py b/src/drf_yasg/inspectors/view.py index c00a79e..8ad8cc8 100644 --- a/src/drf_yasg/inspectors/view.py +++ b/src/drf_yasg/inspectors/view.py @@ -214,8 +214,6 @@ class SwaggerAutoSchema(ViewInspector): default_schema = self.get_default_response_serializer() default_schema = default_schema or '' - if any(is_form_media_type(encoding) for encoding in self.get_consumes()): - default_schema = '' if default_schema and not isinstance(default_schema, openapi.Schema): default_schema = self.serializer_to_schema(default_schema) or '' diff --git a/testproj/users/views.py b/testproj/users/views.py index a031fcf..b261ef6 100644 --- a/testproj/users/views.py +++ b/testproj/users/views.py @@ -6,7 +6,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from drf_yasg import openapi -from drf_yasg.utils import no_body, swagger_auto_schema +from drf_yasg.utils import swagger_auto_schema from users.serializers import UserListQuerySerializer, UserSerializerrr diff --git a/tests/reference.yaml b/tests/reference.yaml index 207220e..5cc8c70 100644 --- a/tests/reference.yaml +++ b/tests/reference.yaml @@ -189,6 +189,8 @@ paths: responses: '200': description: '' + schema: + $ref: '#/definitions/Article' consumes: - multipart/form-data tags: @@ -225,6 +227,8 @@ paths: responses: '201': description: '' + schema: + $ref: '#/definitions/ImageUpload' consumes: - multipart/form-data tags: @@ -887,6 +891,32 @@ definitions: type: string format: uuid readOnly: true + ImageUpload: + required: + - image_styles + type: object + properties: + what_am_i_doing: + description: test + type: string + pattern: ^69$ + default: '69' + minLength: 1 + image_styles: + description: Parameter with Items + type: array + items: + type: string + enum: + - wide + - tall + - thumb + - social + upload: + description: image serializer help_text + type: string + readOnly: true + format: uri Identity: title: Identity type: object