Skip to content

Commit a2c3e4a

Browse files
committed
update postprocessing hook to include the changes in drf-spectatcular 0.29
1 parent 456bce1 commit a2c3e4a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drf_standardized_errors/openapi_hooks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# since it's a copy of drf-spectacular postprocessing hook
33
import re
44
from collections import defaultdict
5+
from collections.abc import MutableMapping
56

67
from drf_spectacular.hooks import postprocess_schema_enum_id_removal
78
from drf_spectacular.plumbing import (
@@ -83,8 +84,8 @@ def extract_hash(schema):
8384
for component_name, props in iter_prop_containers(schemas):
8485
for prop_name, prop_schema in props.items():
8586
if prop_schema.get("type") == "array":
86-
prop_schema = prop_schema.get("items", {})
87-
if "enum" not in prop_schema:
87+
prop_schema = prop_schema.get("items")
88+
if not isinstance(prop_schema, MutableMapping) or "enum" not in prop_schema:
8889
continue
8990

9091
prop_enum_cleaned_hash = extract_hash(prop_schema)
@@ -138,9 +139,9 @@ def extract_hash(schema):
138139
for prop_name, prop_schema in props.items():
139140
is_array = prop_schema.get("type") == "array"
140141
if is_array:
141-
prop_schema = prop_schema.get("items", {})
142+
prop_schema = prop_schema.get("items")
142143

143-
if "enum" not in prop_schema:
144+
if not isinstance(prop_schema, MutableMapping) or "enum" not in prop_schema:
144145
continue
145146

146147
prop_enum_original_list = prop_schema["enum"]

0 commit comments

Comments
 (0)