Skip to content

Commit a99ff26

Browse files
committed
tmp
1 parent 3e1b85c commit a99ff26

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/nrc/conf/includes/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"url": OPENNOTIFICATIES_API_CONTACT_URL,
3232
},
3333
"SERVE_INCLUDE_SCHEMA": False,
34+
"DEFAULT_GENERATOR_CLASS": "nrc.utils.schema.LocalizedSchemaGenerator",
3435
"POSTPROCESSING_HOOKS": [
3536
"drf_spectacular.hooks.postprocess_schema_enums",
3637
"drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields",

src/nrc/utils/schema.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import logging
22

33
from django.conf import settings
4-
from django.utils.translation import gettext_lazy as _
4+
from django.utils.translation import activate, gettext_lazy as _
55

6+
from drf_spectacular.generators import SchemaGenerator
67
from drf_spectacular.openapi import AutoSchema as _AutoSchema
78
from drf_spectacular.utils import OpenApiParameter, OpenApiTypes
89
from rest_framework import exceptions, mixins, serializers
@@ -186,3 +187,10 @@ def get_location_headers(self) -> list[OpenApiParameter]:
186187
]
187188

188189
return []
190+
191+
192+
class LocalizedSchemaGenerator(SchemaGenerator):
193+
def get_schema(self, request=None, public=True):
194+
# Force the schema to be generated in Dutch
195+
activate("nl-nl")
196+
return super().get_schema(request, public)

0 commit comments

Comments
 (0)