Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rest_framework_yaml/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@
except ImportError:
ReturnDict = None
ReturnList = None

try:
# Note: ErrorDetail was introduced in DRF 3.5.0
from rest_framework.exceptions import ErrorDetail
except ImportError:
ErrorDetail = None
9 changes: 8 additions & 1 deletion rest_framework_yaml/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Helper classes for parsers.
"""
from __future__ import unicode_literals

import decimal
import types

from django.utils import six

from .compat import (
yaml, yaml_represent_text, Hyperlink, OrderedDict, ReturnDict, ReturnList
yaml, yaml_represent_text, Hyperlink, OrderedDict, ReturnDict, ReturnList, ErrorDetail
)


Expand Down Expand Up @@ -80,3 +81,9 @@ def represent_mapping(self, tag, mapping, flow_style=None):
ReturnList,
yaml.representer.SafeRepresenter.represent_list
)

if ErrorDetail:
SafeDumper.add_representer(
ErrorDetail,
yaml_represent_text
)