You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The renderers.OpenApiYamlRenderer renderer cannot dump collections.OrderedDict objects. This is the case because the Dumper class inside the render function is inherited from yaml.SafeDumper, which doesn’t support collections.OrderedDict (yaml.Representer does).
To Reproduce
This bug is triggered in my setup when sending an OPTIONS request to the URL for the SpectacularAPIView. I am not entirely sure if this is caused in every setup or if this is specific to my setup.
Making an OPTIONS request, causes the OpenApiYamlRenderer.render function to receive a collections.OrderedDict type, causing the exception yaml.representer.RepresenterError.
To Fix
One of the approaches to address this issue is to add the represent_ordered_dict dumper from yaml.Representer in OpenApiYamlRenderer.render function, e.g.,
The
renderers.OpenApiYamlRenderer
renderer cannot dumpcollections.OrderedDict
objects. This is the case because theDumper
class inside therender
function is inherited fromyaml.SafeDumper
, which doesn’t supportcollections.OrderedDict
(yaml.Representer
does).To Reproduce
This bug is triggered in my setup when sending an OPTIONS request to the URL for the
SpectacularAPIView
. I am not entirely sure if this is caused in every setup or if this is specific to my setup.Making an OPTIONS request, causes the
OpenApiYamlRenderer.render
function to receive acollections.OrderedDict
type, causing the exceptionyaml.representer.RepresenterError
.To Fix
One of the approaches to address this issue is to add the
represent_ordered_dict
dumper fromyaml.Representer
inOpenApiYamlRenderer.render
function, e.g.,Unrelated note: you might also want to change the parameter name
media_type
toaccepted_media_type
, since it is called that way in https://github.com/encode/django-rest-framework/blob/master/rest_framework/renderers.py. This was observed byPyright
, see also https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportIncompatibleMethodOverride.The text was updated successfully, but these errors were encountered: