I use Swagger UI v2.2.0. I have a RESTful method which returns plain text. I want to display this text with line breaks.
At the moment, the returned text contains new line characters, but they are displayed as \n
. The Content-Type
response header is text/plain
.
I can return the text with something else inserted of new line characters (e.g., <br>
tags). I also can change the Content-Type
. I just need actual line breaks in the displayed text.
Is there a way to achieve this?
Not sure if it helps, but I also faced the same issue.
I wanted to execute the following code in nodejs server:
and wanted output like:
but got :
"MyError\nMyErrorStack:\nStackLine1\nStackline2"
so instead i split the string into array as shown used following:
and this printed
This worked for me.
This is currently not possible due to a documented bug in Swagger UI. Reference:
Inconsistent Markdown Newlines #2981
Bug in Model (Definition) Description with newline characters #3078
The second Issue listed, #3078 contains some discussion on overriding the styles used to render that part of the UI, but results appear inconsistent.
Note: I have subscribed to those issues and will update the answer and/or flag to close as no longer relevant when it is resolved.