Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/core/openapi/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from drf_spectacular.openapi import AutoSchema
from drf_spectacular.utils import OpenApiParameter


class BackendAutoSchema(AutoSchema):
global_params = [
OpenApiParameter(
name="Accept-Language", location=OpenApiParameter.HEADER, description="`ko` or `en`. Default value is `ko`"
)
]

def get_override_parameters(self) -> list[OpenApiParameter]:
return super().get_override_parameters() + self.global_params
3 changes: 2 additions & 1 deletion app/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.locale.LocaleMiddleware",
# CORS
"corsheaders.middleware.CorsMiddleware",
# simple-history
Expand Down Expand Up @@ -312,7 +313,7 @@
# Django Rest Framework Settings
REST_FRAMEWORK = {
"DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.NamespaceVersioning",
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_SCHEMA_CLASS": "core.openapi.schemas.BackendAutoSchema",
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
"EXCEPTION_HANDLER": "drf_standardized_errors.handler.exception_handler",
"DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",),
Expand Down