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 li
Not sure if it helps, but I also faced the same issue.
I wanted to execute the following code in nodejs server:
app.post('/xyz', function (req, res) {
res.status(400).send("MyError\nMyErrorStack:\nStackLine1\nStackline2")
}
and wanted output like:
"MyError
MyErrorStack:
StackLine1
Stackline2"
but got :
"MyError\nMyErrorStack:\nStackLine1\nStackline2"
so instead i split the string into array as shown used following:
err.error = errObj.stack.split("\n")
app.post('/xyz', function (req, res) {
res.status(400).send(err)
}
and this printed
"Error": {
"error": [
"Error: ENOENT: no such file or directory, open 'c:\\....'",
" at Error (native)",
" at Object.fs.openSync (fs.js:584:18)",
" at Object.fs.writeFileSync (fs.js:1224:33)",
" at Object.fs.appendFileSync (fs.js:1283:6)",
" at ...",
" at ...",
" at ...",
" at ...",
" at ...",
" at ..."
]
}
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.