I recently updated an application running springfox-swagger2 and springfox-swagger-ui 2.5.0 to use version 2.6.0. The application's API documentation uses <li>
, <b>
and <br>
tags, which were rendered correctly with 2.5.0, but with version 2.6.0 the <li>
and <br>
tags are ignored by the swagger-ui.
What do I have to do to make springfox render the HTML tags again?
The tags are used at the following positions:
ApiInfoBuilder().description("HERE")
@ApiOperation(notes="HERE")
@ApiResponse(message="HERE")
After experimenting with @ApiOperation
annotation I discovered that in version 2.7.0 SpringFox supports Markdown syntax for text formatting (just like Stack Overflow, GitHub, Atlassian and others). See any Markdown syntax guide for reference.
My experiments show that this Swagger annotation and the following YAML definition should be equivalent.
@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>
And the annotation produces this output in Swagger-UI
What do I have to do to make SpringFox render the HTML tags again?
You have to translate your API description to Markdown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With