sup*_*cr7 7 java jax-rs jersey swagger
我正在使用swagger-jersey2-jaxrs版本1.5.15。我在swagger-ui 3.0.9。我使用@SwaggerDefinition 注释和标签向标题添加了描述(因为描述参数现在已弃用)。代码如下:
@Api(tags = { "Hello World" })
@SwaggerDefinition(tags = { @Tag(name = "Hello World", description =
"Description about world: " + " \n" +
"1. Hello " + "\n" +
"2. World " + "<br>"
)})
Run Code Online (Sandbox Code Playgroud)
通过使用它,我能够向“Hello World”标题添加描述。我的问题是我应该如何为每个点添加换行符。我尝试了以下但失败了:
添加"\n"或"<br>"到字符串。\n"不反映换行符,而"<br>"只是将字符串添加"<br>"到呈现的字符串中。
我也尝试使用System.lineSeparator()and
System.getProperty("line.separator")但这给出了错误“注释属性 Tag.description 的值必须是常量表达式”。
当使用上面的第一种方法时,Swagger 会显示一个换行符 notes其他注释参数(不适用于@Api),是否有任何解决方法可以使用它来获取换行符?
欢迎任何建议,提前致谢!:)
您可以使用以下内容:
@SwaggerDefinition(tags = { @Tag(name = "Hello World", description =
"Description about world: <br /> " +
"1. Hello <br /> " + //With <br />, not <br>
"2. World ")})
Run Code Online (Sandbox Code Playgroud)
它对我有用,它给出了以下结果,带有换行符:
玩得开心 !
使用双 " <br>" 或 " \n",swagger 会在下一行显示文本。例如:
@SwaggerDefinition(tags = { @Tag(name = "Hello World", description =
"Description about world: \n\n" +
"1. Hello \n\n" +
"2. World <br><br>"
)})