在 springfox-swagger-ui 中渲染 html
Render html in springfox-swagger-ui
我最近更新了一个应用程序 运行 springfox-swagger2 和 springfox-swagger-ui 2.5.0 以使用版本 2.6.0。应用程序的 API 文档使用 <li>
、<b>
和 <br>
标签,它们在 2.5.0 中正确呈现,但在 2.6.0 版本中 <li>
和<br>
标签被 swagger-ui.
忽略
我需要做什么才能让 springfox 再次渲染 HTML 标签?
标签用在以下位置:
ApiInfoBuilder().description("HERE")
@ApiOperation(notes="HERE")
@ApiResponse(message="HERE")
在尝试使用 @ApiOperation
注释后,我发现在 2.7.0 版本中,SpringFox 支持文本格式化的 Markdown 语法(就像 Stack Overflow、GitHub、Atlassian 等)。请参阅任何 Markdown 语法指南以供参考。
我的实验表明,这个 Swagger 注释和下面的 YAML 定义应该是等价的。
@ApiOperation(value = "Markdown in Swagger API descriptions",
notes = "#Head 1 \n## Head 2 \n###Sorting rules\nThe data is sorted by priority (from the highest to the lowest).<br/> Unordered list \n * item 1.\n * <b>bold item 2</b>\n")
=
summary: Markdown in Swagger API descriptions
description: <h1>Head 1</h1><h2>Head 2</h2><h3>Sorting rules</h3>
The data is sorted by priority (from the highest to the lowest).<br/> Unordered list
<ul><li>item 1.</li><li><b>bold item 2</b></li></ul>
并且注释在 Swagger 中生成此输出-UI
What do I have to do to make SpringFox render the HTML tags again?
您必须将您的 API 描述翻译成 Markdown。
我最近更新了一个应用程序 运行 springfox-swagger2 和 springfox-swagger-ui 2.5.0 以使用版本 2.6.0。应用程序的 API 文档使用 <li>
、<b>
和 <br>
标签,它们在 2.5.0 中正确呈现,但在 2.6.0 版本中 <li>
和<br>
标签被 swagger-ui.
我需要做什么才能让 springfox 再次渲染 HTML 标签?
标签用在以下位置:
ApiInfoBuilder().description("HERE")
@ApiOperation(notes="HERE")
@ApiResponse(message="HERE")
在尝试使用 @ApiOperation
注释后,我发现在 2.7.0 版本中,SpringFox 支持文本格式化的 Markdown 语法(就像 Stack Overflow、GitHub、Atlassian 等)。请参阅任何 Markdown 语法指南以供参考。
我的实验表明,这个 Swagger 注释和下面的 YAML 定义应该是等价的。
@ApiOperation(value = "Markdown in Swagger API descriptions",
notes = "#Head 1 \n## Head 2 \n###Sorting rules\nThe data is sorted by priority (from the highest to the lowest).<br/> Unordered list \n * item 1.\n * <b>bold item 2</b>\n")
=
summary: Markdown in Swagger API descriptions
description: <h1>Head 1</h1><h2>Head 2</h2><h3>Sorting rules</h3>
The data is sorted by priority (from the highest to the lowest).<br/> Unordered list
<ul><li>item 1.</li><li><b>bold item 2</b></li></ul>
并且注释在 Swagger 中生成此输出-UI
What do I have to do to make SpringFox render the HTML tags again?
您必须将您的 API 描述翻译成 Markdown。