From 2c997a8771448dfe680cbc1d7fde8c25ae00f975 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 18 Jan 2024 17:27:17 -0300 Subject: [PATCH] Add tags support to OpenApiWebhook --- drf_spectacular/plumbing.py | 4 ++++ tests/test_webhooks.py | 1 + tests/test_webhooks.yml | 2 ++ 3 files changed, 7 insertions(+) diff --git a/drf_spectacular/plumbing.py b/drf_spectacular/plumbing.py index b32a379b..d35da3aa 100644 --- a/drf_spectacular/plumbing.py +++ b/drf_spectacular/plumbing.py @@ -1458,6 +1458,10 @@ def process_webhooks(webhooks: List[OpenApiWebhook], registry: ComponentRegistry if summary: operation['summary'] = summary + tags = mocked_view.schema.get_tags() + if tags: + operation['tags'] = tags + request_body = mocked_view.schema._get_request_body('response') if request_body: operation['requestBody'] = request_body diff --git a/tests/test_webhooks.py b/tests/test_webhooks.py index 327919cb..0fd5a2b7 100644 --- a/tests/test_webhooks.py +++ b/tests/test_webhooks.py @@ -21,6 +21,7 @@ class EventSerializer(serializers.Serializer): decorator=extend_schema( summary="some summary", description='pushes events to a webhook url as "application/x-www-form-urlencoded"', + tags=["webhooks"], request={ 'application/x-www-form-urlencoded': EventSerializer, }, diff --git a/tests/test_webhooks.yml b/tests/test_webhooks.yml index 6199bb8c..517cf260 100644 --- a/tests/test_webhooks.yml +++ b/tests/test_webhooks.yml @@ -25,6 +25,8 @@ webhooks: post: description: pushes events to a webhook url as "application/x-www-form-urlencoded" summary: some summary + tags: + - webhooks requestBody: content: application/x-www-form-urlencoded: