Skip to content

Commit 48e27ad

Browse files
committed
move the comments for schema generation settings to the settings docs page
1 parent 879dc28 commit 48e27ad

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

docs/settings.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,46 @@ DRF_STANDARDIZED_ERRORS = {
1919
# {field}{NESTED_FIELD_SEPARATOR}{nested_field}
2020
# for example: 'shipping_address.zipcode'
2121
"NESTED_FIELD_SEPARATOR": ".",
22+
23+
# The below settings are for OpenAPI 3 schema generation
24+
25+
# ONLY the responses that correspond to these status codes will appear
26+
# in the API schema.
27+
"ALLOWED_ERROR_STATUS_CODES": [
28+
"400",
29+
"401",
30+
"403",
31+
"404",
32+
"405",
33+
"406",
34+
"415",
35+
"429",
36+
"500",
37+
],
38+
39+
# A mapping used to override the default serializers used to describe
40+
# the error response. The key is the status code and the value is a string
41+
# that represents the path to the serializer class that describes the
42+
# error response.
43+
"ERROR_SCHEMAS": None,
44+
45+
# When there is a validation error in list serializers, the "attr" returned
46+
# will be sth like "0.email", "1.email", "2.email", ... So, to describe
47+
# the error codes linked to the same field in a list serializer, the field
48+
# will appear in the schema with the name "INDEX.email"
49+
"LIST_INDEX_IN_API_SCHEMA": "INDEX",
50+
51+
# When there is a validation error in a DictField with the name "extra_data",
52+
# the "attr" returned will be sth like "extra_data.<key1>", "extra_data.<key2>",
53+
# "extra_data.<key3>", ... Since the keys of a DictField are not predetermined,
54+
# this setting is used as a common name to be used in the API schema. So, the
55+
# corresponding "attr" value for the previous example will be "extra_data.KEY"
56+
"DICT_KEY_IN_API_SCHEMA": "KEY",
57+
58+
# should be unique to error components since it is used to identify error
59+
# components generated dynamically to exclude them from being processed by
60+
# the postprocessing hook. This avoids raising warnings for "code" and "attr"
61+
# which can have the same choices across multiple serializers.
62+
"ERROR_COMPONENT_NAME_SUFFIX": "ErrorComponent",
2263
}
2364
```

drf_standardized_errors/settings.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,9 @@ def reload(self):
7676
"429",
7777
"500",
7878
],
79-
# A mapping used to override the default serializers used to describe
80-
# the error response. The key is the status code and the value is a string
81-
# that represents the path to the serializer class that describes the
82-
# error response.
8379
"ERROR_SCHEMAS": None,
84-
# When there is a validation error in list serializers, the "attr" returned
85-
# will be sth like "0.email", "1.email", "2.email", ... So, to describe
86-
# the error codes linked to the same field in a list serializer, the field
87-
# will appear in the schema with the name "INDEX.email"
8880
"LIST_INDEX_IN_API_SCHEMA": "INDEX",
89-
# When there is a validation error in a DictField with the name "extra_data",
90-
# the "attr" returned will be sth like "extra_data.<key1>", "extra_data.<key2>",
91-
# "extra_data.<key3>", ... Since the keys of a DictField are not predetermined,
92-
# this setting is used as a common name to be used in the API schema. So, the
93-
# corresponding "attr" value for the previous example will be "extra_data.KEY"
9481
"DICT_KEY_IN_API_SCHEMA": "KEY",
95-
# should be unique to error components since it is used to identify error
96-
# components generated dynamically to exclude them from being processed by
97-
# the postprocessing hook. This avoids raising warnings for "code" and "attr"
98-
# which can have the same choices across multiple serializers.
9982
"ERROR_COMPONENT_NAME_SUFFIX": "ErrorComponent",
10083
}
10184

0 commit comments

Comments
 (0)