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

should doc strings render as markdown? #53

Closed
blynn99 opened this issue Jan 17, 2023 · 2 comments
Closed

should doc strings render as markdown? #53

blynn99 opened this issue Jan 17, 2023 · 2 comments
Labels
bug Something isn't working Stale

Comments

@blynn99
Copy link

blynn99 commented Jan 17, 2023

Environment:

  • Python version: 3.7
  • Operating system: windows or ubuntu 18.04
  • Flask version: 1.1.4
  • flask-openapi3 version:

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

doc_description = lines[0] if len(lines) == 0 else "</br>".join(lines[1:]) or None
else:
doc_description = "</br>".join(lines) or None

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.

@blynn99 blynn99 added the bug Something isn't working label Jan 17, 2023
@luolingchun
Copy link
Owner

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

@github-actions github-actions bot added the Stale label Jun 1, 2023
Copy link

github-actions bot commented Jun 1, 2024

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants