parent
5cd642c9a0
commit
a5eb3dfa91
|
|
@ -16,6 +16,7 @@ Changelog
|
|||
*NOTE:* in order for this to work, you will have to add the new ``drf_yasg.inspectors.SerializerMethodFieldInspector``
|
||||
to your ``DEFAULT_FIELD_INSPECTORS`` array if you changed it from the default value
|
||||
|
||||
- **ADDED:** added ``EXCLUDED_MEDIA_TYPES`` setting for controlling ``produces`` MIME type filtering (:issue:`158`)
|
||||
- **IMPROVED:** updated ``swagger-ui`` to version 3.18.0
|
||||
- **IMPROVED:** added ``operation_summary`` and ``deprecated`` arguments to ``swagger_auto_schema``
|
||||
(:issue:`149`, :issue:`173`)
|
||||
|
|
|
|||
|
|
@ -105,6 +105,14 @@ Paginator inspectors given to :func:`@swagger_auto_schema <.swagger_auto_schema>
|
|||
Swagger document attributes
|
||||
===========================
|
||||
|
||||
EXCLUDED_MEDIA_TYPES
|
||||
--------------------
|
||||
|
||||
A list of keywords for excluding MIME types from ``Operation.produces``. Any MIME type string which includes one of
|
||||
the substrings in this list will be prevented from appearing in a ``produces`` array in the Swagger document.
|
||||
|
||||
**Default**: :python:`['html']`
|
||||
|
||||
.. _default-swagger-settings:
|
||||
|
||||
DEFAULT_INFO
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ SWAGGER_DEFAULTS = {
|
|||
'drf_yasg.inspectors.CoreAPICompatInspector',
|
||||
],
|
||||
|
||||
'EXCLUDED_MEDIA_TYPES': ['html'],
|
||||
|
||||
'DEFAULT_INFO': None,
|
||||
'DEFAULT_API_URL': None,
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ from rest_framework.settings import api_settings as rest_framework_settings
|
|||
from rest_framework.utils import encoders, json
|
||||
from rest_framework.views import APIView
|
||||
|
||||
from drf_yasg.app_settings import swagger_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -328,7 +330,7 @@ def get_produces(renderer_classes):
|
|||
:rtype: list[str]
|
||||
"""
|
||||
media_types = [renderer.media_type for renderer in renderer_classes or []]
|
||||
media_types = [encoding for encoding in media_types if 'html' not in encoding]
|
||||
media_types = [encoding for encoding in media_types if not any(excluded in encoding for excluded in swagger_settings.EXCLUDED_MEDIA_TYPES)]
|
||||
return media_types
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue