|
2 | 2 | # since it's a copy of drf-spectacular postprocessing hook |
3 | 3 | import re |
4 | 4 | from collections import defaultdict |
| 5 | +from collections.abc import MutableMapping |
5 | 6 |
|
6 | 7 | from drf_spectacular.hooks import postprocess_schema_enum_id_removal |
7 | 8 | from drf_spectacular.plumbing import ( |
@@ -83,8 +84,8 @@ def extract_hash(schema): |
83 | 84 | for component_name, props in iter_prop_containers(schemas): |
84 | 85 | for prop_name, prop_schema in props.items(): |
85 | 86 | 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: |
88 | 89 | continue |
89 | 90 |
|
90 | 91 | prop_enum_cleaned_hash = extract_hash(prop_schema) |
@@ -138,9 +139,9 @@ def extract_hash(schema): |
138 | 139 | for prop_name, prop_schema in props.items(): |
139 | 140 | is_array = prop_schema.get("type") == "array" |
140 | 141 | if is_array: |
141 | | - prop_schema = prop_schema.get("items", {}) |
| 142 | + prop_schema = prop_schema.get("items") |
142 | 143 |
|
143 | | - if "enum" not in prop_schema: |
| 144 | + if not isinstance(prop_schema, MutableMapping) or "enum" not in prop_schema: |
144 | 145 | continue |
145 | 146 |
|
146 | 147 | prop_enum_original_list = prop_schema["enum"] |
|
0 commit comments