From b2821d168c58281fe4ff8e255c95aa39f5b84b0c Mon Sep 17 00:00:00 2001 From: Seiji Chew <67301797+schew2381@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:09:00 -0700 Subject: [PATCH] fix(docs): Correct model serializer ordering of body params (#57884) Took me a bit but I finally found out that for model serializers, body params are specified by the order in which the fields are listed in the model serializer's `class Meta` section. The ordering is changing when I change the order of the TypedDict b/c the fields are defined by that TypedDict (see below) https://github.com/getsentry/sentry/blob/cae2b6113536e44d5fe99a64ed642a7073fe05c9/src/sentry/api/serializers/rest_framework/notification_action.py#L348-L350 ### New Body Params for Spike Protection (shared by Create + Updated) Screenshot 2023-10-10 at 6 45 46 PM --- .../rest_framework/notification_action.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sentry/api/serializers/rest_framework/notification_action.py b/src/sentry/api/serializers/rest_framework/notification_action.py index 3d13f29d2f71d2..0d8000cd821f5c 100644 --- a/src/sentry/api/serializers/rest_framework/notification_action.py +++ b/src/sentry/api/serializers/rest_framework/notification_action.py @@ -28,15 +28,16 @@ def format_choices_text(choices: List[Tuple[int, str]]): } +# Note the ordering of fields affects the Spike Protection API Documentation class NotificationActionInputData(TypedDict): - integration_id: int - sentry_app_id: int - projects: List[Project] - service_type: int trigger_type: int - target_type: int + service_type: int + integration_id: int target_identifier: str target_display: str + projects: List[Project] + sentry_app_id: int + target_type: int @extend_schema_serializer(exclude_fields=["sentry_app_id", "target_type"]) @@ -46,10 +47,10 @@ class NotificationActionSerializer(CamelSnakeModelSerializer): """ trigger_type = serializers.CharField( - help_text="""Type of the trigger that causes the notification. The only supported trigger right now is: `spike-protection`""" + help_text="""Type of the trigger that causes the notification. The only supported trigger right now is: `spike-protection`.""" ) service_type = serializers.CharField( - help_text="Service that is used for sending the notification\n" + help_text="Service that is used for sending the notification.\n" + """- `email`\n""" + """- `slack`\n""" + """- `sentry_notification`\n""" @@ -80,7 +81,7 @@ class NotificationActionSerializer(CamelSnakeModelSerializer): required=False, ) projects = serializers.ListField( - help_text="""List of projects slugs that the Notification Action is created for""", + help_text="""List of projects slugs that the Notification Action is created for.""", child=ProjectField(scope="project:read"), required=False, )