luolingchun / flask-openapi3

Generate REST API and OpenAPI documentation for your Flask project.
https://luolingchun.github.io/flask-openapi3/
MIT License
204 stars 33 forks source link

should doc strings render as markdown? #53

Closed blynn99 closed 6 months ago

blynn99 commented 1 year ago

Environment:

Should get_operation add </br> to doc strings? If the description has line feeds \n vs </br> the description renders as markdown.

https://github.com/luolingchun/flask-openapi3/blob/6ca0f2c6a5b90a5ae439c432b0a3e6f8cf9c4d21/flask_openapi3/utils.py#L27-L29

code diff

index fd194d8..c5f0db9 100644
--- a/flask_openapi3/utils.py
+++ b/flask_openapi3/utils.py
@@ -24,9 +24,9 @@ def get_operation(func: Callable, *, summary: Optional[str] = None, description:
     lines = doc.split("\n")
     doc_summary = lines[0] or None
     if summary is None:
-        doc_description = lines[0] if len(lines) == 0 else "</br>".join(lines[1:]) or None
+        doc_description = lines[0] if len(lines) == 0 else "\n".join(lines[1:]) or None
     else:
-        doc_description = "</br>".join(lines) or None
+        doc_description = "\n".join(lines) or None
     operation = Operation(
         summary=summary or doc_summary,
         description=description or doc_description

example endpoint:

@blueprint.post('/test', responses={...})
def test(body: ....):
    """
    my summary

   Examples:
   test with `some param`
   ...

   """
   return {}

With \n vs </br> the above example will render the markdown from the docstring into HTML. This is useful when providing some additional usage/example to the endpoint's documentation.

luolingchun commented 1 year ago

I don't understand what you want to express. Is there anything wrong with this?

github-actions[bot] commented 6 months ago

This issue has been automatically closed because we haven't heard back for more than 365 days, please reopen this issue if necessary.