Skip to content

Commit f374319

Browse files
📚 docs(README): Update readme documentation to add new config
1 parent 30c219d commit f374319

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ Here are the default settings that are automatically applied:
300300
# settings.py
301301
302302
RESPONSE_SHAPER_DEBUG_MODE = False
303+
RESPONSE_SHAPER_RETURN_ERROR_AS_DICT = True
303304
RESPONSE_SHAPER_EXCLUDED_PATHS = ["/admin/", "/schema/swagger-ui/", "/schema/redoc/", "/schema/"]
304305
RESPONSE_SHAPER_SUCCESS_HANDLER = ""
305306
RESPONSE_SHAPER_ERROR_HANDLER = ""
@@ -313,6 +314,24 @@ RESPONSE_SHAPER_ERROR_HANDLER = ""
313314
- **Description**: When set to `True`, disables response shaping for debugging purposes.
314315
- **Default**: `False`
315316

317+
`RESPONSE_SHAPER_RETURN_ERROR_AS_DICT`
318+
--------------------------------------
319+
320+
- **Type**: `bool`
321+
- **Description**: Controls the format of dict error messages extracted by the ExceptionHandler. When `True`, errors with **nested dictionary** structure are returned as a dictionary containing the innermost key-value pair from nested error structures. When `False`, only the innermost error message is returned as a string. This applies to error responses shaped by the handler, particularly for validation.
322+
- **Default**: `True`
323+
324+
**Example**:
325+
```python
326+
# With RESPONSE_SHAPER_RETURN_ERROR_AS_DICT = True
327+
error_input = {"field": {"detail": {"code": "invalid"}}}
328+
# Result: {"code": "invalid"}
329+
330+
# With RESPONSE_SHAPER_RETURN_ERROR_AS_DICT = False
331+
error_input = {"field": {"detail": {"code": "invalid"}}}
332+
# Result: "invalid"
333+
```
334+
316335
`RESPONSE_SHAPER_EXCLUDED_PATHS`
317336
--------------------------------
318337

0 commit comments

Comments
 (0)