Skip to content

Commit ec16393

Browse files
authored
feat: Add page search schema extension for exact match queries (#79)
1 parent 3ee81b2 commit ec16393

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

djangocms_rest/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@
6161
]
6262
)
6363

64+
extend_page_search_schema = extend_schema(
65+
parameters=[
66+
OpenApiParameter(
67+
name="q",
68+
type=OpenApiTypes.STR,
69+
location=OpenApiParameter.QUERY,
70+
description="Search for an exact match of the search term to find pages by title, page_title, menu_title, or meta_description",
71+
required=False,
72+
),
73+
]
74+
)
75+
6476
except ImportError: # pragma: no cover
6577

6678
class OpenApiTypes:
@@ -85,6 +97,9 @@ def _decorator(obj: T) -> T:
8597
def extend_placeholder_schema(func: Callable[P, T]) -> Callable[P, T]:
8698
return func
8799

100+
def extend_page_search_schema(func: Callable[P, T]) -> Callable[P, T]:
101+
return func
102+
88103

89104
# Generate the plugin definitions once at module load time
90105
# This avoids the need to import the plugin definitions in every view
@@ -137,6 +152,7 @@ def get_queryset(self):
137152

138153

139154
class PageSearchView(PageListView):
155+
@extend_page_search_schema
140156
def get(self, request, language: str | None = None) -> Response:
141157
self.search_term = request.GET.get("q", "")
142158
self.language = language

0 commit comments

Comments
 (0)