From e78d69695d1cc5f19bbbb8f2a9c44b836a147cfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 27 Sep 2019 16:55:18 +0200 Subject: [PATCH] Ensure proper arguments in swagger decorator --- openedx/core/openapi.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openedx/core/openapi.py b/openedx/core/openapi.py index d4c056d6d2..a58aa6085a 100644 --- a/openedx/core/openapi.py +++ b/openedx/core/openapi.py @@ -55,9 +55,11 @@ def swagger_auto_schema(*args, **kwargs): __ https://drf-yasg.readthedocs.io/en/stable/drf_yasg.html#drf_yasg.utils.swagger_auto_schema """ - if args and callable(args[0]): - # decorator may be used with no argument - return swagger_auto_schema(*args[1:], **kwargs)(args[0]) + if args: + if callable(args[0]): + # decorator may be used with no argument + return swagger_auto_schema(*args[1:], **kwargs)(args[0]) + raise ValueError("Unsupported positional arguments") for param in kwargs.get('manual_parameters', ()): param.description = dedent(param.description)