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 summary field to extend_schema #97

Merged
merged 4 commits into from
Jun 17, 2020
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/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def get_operation(self, path, path_regex, method, registry: ComponentRegistry):
self.method = method

operation = {}

summary = self.get_summary()
if summary:
operation['summary'] = summary

operation['operationId'] = self.get_operation_id()
operation['description'] = self.get_description()
Expand Down
6 changes: 6 additions & 0 deletions drf_spectacular/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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):
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
Expand Down