Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags support to OpenApiWebhook #1146

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions drf_spectacular/plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 2 additions & 0 deletions tests/test_webhooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down