Skip to content

Commit

Permalink
fix(docs): Correct model serializer ordering of body params (#57884)
Browse files Browse the repository at this point in the history
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)
<img width="484" alt="Screenshot 2023-10-10 at 6 45 46 PM"
src="https://github.com/getsentry/sentry/assets/67301797/37cba172-3216-41e8-b0f8-85b2ad523126">
  • Loading branch information
schew2381 authored Oct 12, 2023
1 parent f0a558b commit b2821d1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/sentry/api/serializers/rest_framework/notification_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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"""
Expand Down Expand Up @@ -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,
)
Expand Down

0 comments on commit b2821d1

Please sign in to comment.