From 111ef9c5d246aa04688a37b8af66dc1e62c3b049 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 11 Jan 2024 21:56:10 -0300 Subject: [PATCH] Default WEBHOOKS setting to an empty list --- drf_spectacular/plumbing.py | 5 +---- drf_spectacular/settings.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drf_spectacular/plumbing.py b/drf_spectacular/plumbing.py index 349aae4a..e9a22ad3 100644 --- a/drf_spectacular/plumbing.py +++ b/drf_spectacular/plumbing.py @@ -1408,7 +1408,7 @@ def build_serializer_context(view) -> typing.Dict[str, Any]: return {'request': view.request} -def process_webhooks(webhooks: Union[List[OpenApiWebhook], None], registry: ComponentRegistry) -> _SchemaType: +def process_webhooks(webhooks: List[OpenApiWebhook], registry: ComponentRegistry) -> _SchemaType: """ Creates a mocked view for every webhook. The given extend_schema decorator then specifies the expectations on the receiving end of the callback. Effectively @@ -1416,9 +1416,6 @@ def process_webhooks(webhooks: Union[List[OpenApiWebhook], None], registry: Comp """ result = {} - if webhooks is None: - return result - for webhook in webhooks: if isinstance(webhook.decorator, dict): methods = webhook.decorator diff --git a/drf_spectacular/settings.py b/drf_spectacular/settings.py index 936c74dd..629b6114 100644 --- a/drf_spectacular/settings.py +++ b/drf_spectacular/settings.py @@ -201,7 +201,7 @@ 'TAGS': [], # Optional: List of OpenAPI 3.1 webhooks. Each entry should be an import path to an # OpenApiWebhook instance. - 'WEBHOOKS': None, + 'WEBHOOKS': [], # Optional: MUST contain 'url', may contain "description" 'EXTERNAL_DOCS': {},