From 71c07bf89407afb435ad8c3fe1943d7747650135 Mon Sep 17 00:00:00 2001 From: lilisha100 Date: Tue, 16 Jun 2020 11:37:30 -0700 Subject: [PATCH 1/4] Update openapi.py --- drf_spectacular/openapi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drf_spectacular/openapi.py b/drf_spectacular/openapi.py index c0dcd978..110fc921 100644 --- a/drf_spectacular/openapi.py +++ b/drf_spectacular/openapi.py @@ -47,6 +47,10 @@ def get_operation(self, path, path_regex, method, registry: ComponentRegistry): self.method = method operation = {} + + summary = self.get_summary(path, method) + if summary: + operation['summary'] = summary operation['operationId'] = self.get_operation_id() operation['description'] = self.get_description() From 261b1f841c2c783726c969c6083595b54285ebfd Mon Sep 17 00:00:00 2001 From: lilisha100 Date: Tue, 16 Jun 2020 11:41:46 -0700 Subject: [PATCH 2/4] Add summary field to extend_schema Add summary field to extend_schema so that the generated openapi spec file can have a summary field. --- drf_spectacular/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drf_spectacular/utils.py b/drf_spectacular/utils.py index f2008dd8..e640327e 100644 --- a/drf_spectacular/utils.py +++ b/drf_spectacular/utils.py @@ -46,6 +46,7 @@ def __init__(self, name, type=str, location=QUERY, required=False, description=' def extend_schema( + summary=None, operation_id=None, parameters=None, request=None, @@ -63,6 +64,7 @@ def extend_schema( decorator for the "view" kind. partially or completely overrides what would be generated by drf-spectacular. + :param summary: An optional, string summary, intended to apply to all operations in this path. :param operation_id: replaces the auto-generated operation_id. make sure there are no naming collisions. :param parameters: list of additional or replacement parameters added to the @@ -122,6 +124,10 @@ def get_operation(self, path, path_regex, method, registry): return operation return super().get_operation(path, path_regex, method, registry) + def get_summary(self, path, method): + if summary and is_in_scope(self): + return summary + def get_operation_id(self): if operation_id and is_in_scope(self): return operation_id From 6bde6cb7fc8f1befa4e0822c95979ea7fe5cd865 Mon Sep 17 00:00:00 2001 From: lilisha100 Date: Tue, 16 Jun 2020 13:14:51 -0700 Subject: [PATCH 3/4] Update openapi.py --- drf_spectacular/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drf_spectacular/openapi.py b/drf_spectacular/openapi.py index 110fc921..ea8aa4ea 100644 --- a/drf_spectacular/openapi.py +++ b/drf_spectacular/openapi.py @@ -48,7 +48,7 @@ def get_operation(self, path, path_regex, method, registry: ComponentRegistry): operation = {} - summary = self.get_summary(path, method) + summary = self.get_summary() if summary: operation['summary'] = summary From 2a8c35242ca7f9fb7c0f9caf79345d38fd2298a7 Mon Sep 17 00:00:00 2001 From: lilisha100 Date: Tue, 16 Jun 2020 13:15:29 -0700 Subject: [PATCH 4/4] Update utils.py --- drf_spectacular/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drf_spectacular/utils.py b/drf_spectacular/utils.py index e640327e..6ac283a6 100644 --- a/drf_spectacular/utils.py +++ b/drf_spectacular/utils.py @@ -124,7 +124,7 @@ def get_operation(self, path, path_regex, method, registry): return operation return super().get_operation(path, path_regex, method, registry) - def get_summary(self, path, method): + def get_summary(self): if summary and is_in_scope(self): return summary