diff --git a/zerver/webhooks/gitlab/view.py b/zerver/webhooks/gitlab/view.py index 2c867c641d..cde6ac75a0 100644 --- a/zerver/webhooks/gitlab/view.py +++ b/zerver/webhooks/gitlab/view.py @@ -3,13 +3,15 @@ from functools import partial from typing import Dict, List, Optional, Protocol, Union from django.http import HttpRequest, HttpResponse +from pydantic import Json from zerver.decorator import webhook_view from zerver.lib.exceptions import UnsupportedWebhookEventTypeError -from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success -from zerver.lib.validator import WildValue, check_bool, check_int, check_string, to_wild_value +from zerver.lib.typed_endpoint import WebhookPayload, typed_endpoint +from zerver.lib.validator import WildValue, check_int, check_string from zerver.lib.webhooks.common import ( + OptionalUserSpecifiedTopicStr, check_send_webhook_message, validate_extract_webhook_http_header, ) @@ -416,14 +418,15 @@ ALL_EVENT_TYPES = list(EVENT_FUNCTION_MAPPER.keys()) @webhook_view("GitLab", all_event_types=ALL_EVENT_TYPES) -@has_request_variables +@typed_endpoint def api_gitlab_webhook( request: HttpRequest, user_profile: UserProfile, - payload: WildValue = REQ(argument_type="body", converter=to_wild_value), - branches: Optional[str] = REQ(default=None), - use_merge_request_title: bool = REQ(default=True, json_validator=check_bool), - user_specified_topic: Optional[str] = REQ("topic", default=None), + *, + payload: WebhookPayload[WildValue], + branches: Optional[str] = None, + use_merge_request_title: Json[bool] = True, + user_specified_topic: OptionalUserSpecifiedTopicStr = None, ) -> HttpResponse: event = get_event(request, payload, branches) if event is not None: