添加换行符以摇摇欲坠的输出 [英] Add a newline to swagger output
问题描述
我正在使用swagger-jersey2-jaxrs
版本1.5.15
.我在swagger-ui 3.0.9
上.我使用@SwaggerDefinition批注和标签在标头中添加了说明(因为不推荐使用description参数).代码如下:
I am using swagger-jersey2-jaxrs
version 1.5.15
. I am on swagger-ui 3.0.9
. I added a description to a header using @SwaggerDefinition annotation and tags (as the description parameter is now deprecated). The code goes like:
@Api(tags = { "Hello World" })
@SwaggerDefinition(tags = { @Tag(name = "Hello World", description =
"Description about world: " + " \n" +
"1. Hello " + "\n" +
"2. World " + "<br>"
)})
使用此功能,我可以在"Hello World"标题中添加说明.我的问题是我应该如何为每个点添加换行符.我尝试了以下操作,但失败了:
By using this, I was able to add a description to the "Hello World" header. My question is how should I add a newline for every point. I tried the following but failed:
-
在字符串中添加
"\n"
或"<br>"
.\n"
不能反映 换行符,而"<br>"
只是将字符串"<br>"
添加到字符串中 呈现.
Adding
"\n"
or"<br>"
to string.\n"
doesn't reflect a newline while"<br>"
just adds the string"<br>"
to the string that is rendered.
我尝试使用System.lineSeparator()
和
System.getProperty("line.separator")
也是这样,
错误注释属性Tag.description的值必须是
常数表达式".
I tried to use System.lineSeparator()
and
System.getProperty("line.separator")
as well but that gives the
error "The value for annotation attribute Tag.description must be a
constant expression".
在将notes
参数用于其他注释时,使用上述第一种方法时,Swagger显示换行符(不适用于@Api),可以使用任何替代方法来获取换行符吗?
Swagger shows a newline when the first method above is used when using the notes
parameter for the other annotations (doesn't work with @Api), any workaround to using that instead to get the newline?
任何建议都是值得欢迎的,在此先感谢! :)
Any suggestion is welcome, thanks in advance! :)
推荐答案
您可以使用以下内容:
@SwaggerDefinition(tags = { @Tag(name = "Hello World", description =
"Description about world: <br /> " +
"1. Hello <br /> " + //With <br />, not <br>
"2. World ")})
它对我有用,它给出以下结果,并带有换行符:
It works for me, it gives the following result, with line breaks:
玩得开心!
这篇关于添加换行符以摇摇欲坠的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!