Skip to content

Commit

Permalink
Integrate standardized error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kdsuneraavinash committed Sep 16, 2023
1 parent fa9c95f commit 9ac6116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"constance",
"constance.backends.database",
"anymail",
"drf_standardized_errors",
]
LOCAL_APPS = [
"apps.api_auth.apps.ApiAuthConfig",
Expand Down Expand Up @@ -281,8 +282,9 @@
"rest_framework_simplejwt.authentication.JWTAuthentication",
"dj_rest_auth.jwt_auth.JWTCookieAuthentication",
],
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_SCHEMA_CLASS": "drf_standardized_errors.openapi.AutoSchema",
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
"EXCEPTION_HANDLER": "drf_standardized_errors.handler.exception_handler",
}
# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
# Enable CORS to all API endpoints.
Expand Down Expand Up @@ -313,6 +315,20 @@
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
"SERVE_AUTHENTICATION": ["rest_framework.authentication.SessionAuthentication"],
"AUTHENTICATION_WHITELIST": ["rest_framework_simplejwt.authentication.JWTAuthentication"],
"POSTPROCESSING_HOOKS": ["drf_standardized_errors.openapi_hooks.postprocess_schema_enums"],
"ENUM_NAME_OVERRIDES": {
"ValidationErrorEnum": "drf_standardized_errors.openapi_serializers.ValidationErrorEnum.values",
"ClientErrorEnum": "drf_standardized_errors.openapi_serializers.ClientErrorEnum.values",
"ServerErrorEnum": "drf_standardized_errors.openapi_serializers.ServerErrorEnum.values",
"ErrorCode401Enum": "drf_standardized_errors.openapi_serializers.ErrorCode401Enum.values",
"ErrorCode403Enum": "drf_standardized_errors.openapi_serializers.ErrorCode403Enum.values",
"ErrorCode404Enum": "drf_standardized_errors.openapi_serializers.ErrorCode404Enum.values",
"ErrorCode405Enum": "drf_standardized_errors.openapi_serializers.ErrorCode405Enum.values",
"ErrorCode406Enum": "drf_standardized_errors.openapi_serializers.ErrorCode406Enum.values",
"ErrorCode415Enum": "drf_standardized_errors.openapi_serializers.ErrorCode415Enum.values",
"ErrorCode429Enum": "drf_standardized_errors.openapi_serializers.ErrorCode429Enum.values",
"ErrorCode500Enum": "drf_standardized_errors.openapi_serializers.ErrorCode500Enum.values",
},
}

# ---------------------------------------------------------- Django Constance ------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ django-filter==23.2
Pillow==10.0.1
django-anymail==10.1
drf-spectacular==0.26.4
drf-standardized-errors[openapi]==0.12.5

# ---------------------------------------------------------- Admin Panel -----------------------------------------------
django-admin-interface==0.26.1
Expand Down

0 comments on commit 9ac6116

Please sign in to comment.