Skip to content

Swagger: add summary on method documentation #109

@albinpopote

Description

@albinpopote

Is your feature request related to a problem? Please describe.
I have not found the mean to add the summary of a method with api.doc decorator.
It seems to be hardcoded in swagger.py at line 448:
"summary": doc[method]["docstring"]["summary"],

Describe the solution you'd like
As the description on the same method, replace the line by :

        "summary": self.summary_for( doc, method) or None,

And create the following method:

def summary_for(self, doc, method):
    """Extract the summay metadata and fallback on the whole docstring"""
    parts = []
    if "summary" in doc:
        parts.append(doc["summary"] or "")
    if method in doc and "summary" in doc[method]:
        parts.append(doc[method]["summary"])
    if doc[method]["docstring"]["summary"]:
        parts.append(doc[method]["docstring"]["summary"])

    return "\n".join(parts).strip()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions