Skip to content

Commit aef3902

Browse files
authored
[#240] Fix for br tag rendering (#241)
Updates the br tag rendering to properly output <br/> instead of </br>
1 parent a98af06 commit aef3902

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

flask_openapi3/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def get_operation(
7878

7979
# Determine the summary and description based on provided arguments or docstring
8080
if summary is None:
81-
doc_description = lines[0] if len(lines) == 0 else "</br>".join(lines[1:])
81+
doc_description = lines[0] if len(lines) == 0 else "<br/>".join(lines[1:])
8282
else:
83-
doc_description = "</br>".join(lines)
83+
doc_description = "<br/>".join(lines)
8484

8585
summary = summary or doc_summary
8686
description = description or doc_description

tests/test_api_blueprint.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ def delete_book(path: BookPath):
9797
return {"code": 0, "message": "ok"}
9898

9999

100+
@api.get("/book/<int:bid>")
101+
def get_book(path: BookPath):
102+
"""Get Book
103+
Here is a book
104+
Here's another line in the description
105+
"""
106+
return {"title": "test", "Author": "author"}
107+
108+
100109
# register api
101110
app.register_api(api)
102111

@@ -107,6 +116,8 @@ def test_openapi(client):
107116
assert resp.json == app.api_doc
108117
assert resp.json["paths"]["/api/book/{bid}"]["put"]["operationId"] == "update"
109118
assert resp.json["paths"]["/api/book/{bid}"]["delete"]["operationId"] == "delete_book"
119+
expected_description = "Here is a book<br/>Here's another line in the description"
120+
assert resp.json["paths"]["/api/book/{bid}"]["get"]["description"] == expected_description
110121

111122

112123
def test_post(client):

0 commit comments

Comments
 (0)