-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #482 from dandi/enh-1line-docstring
ENH(UX): overload @swagger_auto_schema to show one-line docstrings as summary
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Separate from settings.py due to being a somewhat of a premature import there. | ||
# See https://github.com/dandi/dandi-api/pull/482#issuecomment-901250541 . | ||
from drf_yasg.inspectors import SwaggerAutoSchema | ||
|
||
|
||
class DANDISwaggerAutoSchema(SwaggerAutoSchema): | ||
"""Custom class for @swagger_auto_schema to provide summary from one line docstrings. | ||
See https://github.com/axnsan12/drf-yasg/issues/205 and | ||
https://github.com/axnsan12/drf-yasg/issues/265 for more information on why it is not | ||
a default behavior. | ||
""" | ||
|
||
def split_summary_from_description(self, description): | ||
summary, description = super().split_summary_from_description(description) | ||
if summary is None: | ||
return description, None | ||
else: | ||
return summary, description |