Fix lint errors
parent
a872eb66d6
commit
17da098940
|
|
@ -1,3 +1,5 @@
|
|||
from six import binary_type, raise_from, text_type
|
||||
|
||||
import copy
|
||||
import json
|
||||
import logging
|
||||
|
|
@ -6,8 +8,6 @@ from collections import OrderedDict
|
|||
from coreapi.compat import force_bytes
|
||||
from ruamel import yaml
|
||||
|
||||
from six import binary_type, raise_from, text_type
|
||||
|
||||
from . import openapi
|
||||
from .errors import SwaggerValidationError
|
||||
|
||||
|
|
|
|||
|
|
@ -375,13 +375,15 @@ def get_consumes(parser_classes):
|
|||
parser_classes = [pc for pc in parser_classes if not issubclass(pc, FileUploadParser)]
|
||||
media_types = [parser.media_type for parser in parser_classes or []]
|
||||
non_form_media_types = [encoding for encoding in media_types if not is_form_media_type(encoding)]
|
||||
# Because some data to parse could be nested array and are not supported by form media type like multipart/form-data,
|
||||
# we must be sure to have explicit form media types **only**.
|
||||
# Because swagger Parameter objects don't support complex data types (nested objects, arrays),
|
||||
# we can't use those unless we are sure the view *only* accepts form data
|
||||
# This means that a view won't support file upload in swagger unless it explicitly
|
||||
# sets its parser classes to include only form parsers
|
||||
if len(non_form_media_types) == 0:
|
||||
return media_types
|
||||
# Otherwise, enforce a media type like application/json to be able to parse nested array, but it won't be able to
|
||||
# support file upload...
|
||||
else:
|
||||
|
||||
# If the form accepts both form data and another type, like json (which is the default config),
|
||||
# we will render its input as a Schema and thus it file parameters will be read-only
|
||||
return non_form_media_types
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ from django.conf.urls import url
|
|||
from django.contrib.postgres import fields as postgres_fields
|
||||
from django.db import models
|
||||
from django.utils.inspect import get_func_args
|
||||
from django_fake_model import models as fake_models
|
||||
from rest_framework import routers, serializers, viewsets
|
||||
from rest_framework.decorators import api_view
|
||||
from rest_framework.response import Response
|
||||
|
||||
from django_fake_model import models as fake_models
|
||||
from drf_yasg import codecs, openapi
|
||||
from drf_yasg.codecs import yaml_sane_load
|
||||
from drf_yasg.errors import SwaggerGenerationError
|
||||
|
|
@ -347,6 +347,7 @@ EXPECTED_DESCRIPTION = """\
|
|||
You can log in using the pre-existing `admin` user with password `passwordadmin`.
|
||||
"""
|
||||
|
||||
|
||||
def test_multiline_strings(call_generate_swagger):
|
||||
output = call_generate_swagger(format='yaml')
|
||||
print("|\n|".join(output.splitlines()[:20]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue