Do not bail on response when request body is formData

openapi3
Cristi Vîjdea 2018-09-10 00:02:23 +03:00
parent b109d4c847
commit 41b1ca4483
4 changed files with 35 additions and 3 deletions

View File

@ -16,7 +16,11 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testproj" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.pytest_cache" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
<excludeFolder url="file://$MODULE_DIR$/docs/_build" />
<excludeFolder url="file://$MODULE_DIR$/htmlcov" />
<excludeFolder url="file://$MODULE_DIR$/src/drf_yasg.egg-info" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3 (drf-yasg)" jdkType="Python SDK" />

View File

@ -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 ''

View File

@ -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

View File

@ -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