I want to make Capo Mastro a clickable link in Java for swagger in @ApiOperation annotation, but I can't get any result.
@ApiOperation(
value = "This method updates an existing capo mastro."+" <a href>Capo mastro<a>"+ can be managed only by system",
response = SaveCapoMastroResponse.class
)
I would really appreciate if anyone could help! Thank you!
答案 0 :(得分:2)
假设您在Swagger UI中表示可点击 - 您可以使用Markdown语法在操作说明(notes
属性)中添加链接。操作摘要(value
)不支持Markdown。
@ApiOperation(
value = "This method updates an existing capo mastro.",
notes = "[Capo mastro](http://example.com) can be managed only by system.",
response = SaveCapoMastroResponse.class
)
HTML <a href="">
标记也应该有用,因为Markdown支持HTML。确保转义内部"
引号。
@ApiOperation(
value = "This method updates an existing capo mastro.",
notes = "<a href=\"http://example.com\" target=\"_blank\">Capo mastro</a> can be managed only by system.",
response = SaveCapoMastroResponse.class
)
答案 1 :(得分:1)
您可以使用 @ExternalDocs 批注为api指定链接,如下所示:
@ExternalDocs(value="Capo mastro", url="link to Capo mastro")
答案 2 :(得分:0)
我在说明中添加了可点击的图片徽标:
private static ApiInfo v1ApiInfo() {
return new ApiInfoBuilder()
.version("1.0")
.title("Council on Dairy Cattle Breeding (CDCB) API v1.0 Documentation"))
.description("[![cdcb](/img/cdcb.png)](https://www.uscdcb.com/)").build();
}
/img/cdcb.png
- 这是来自可用资源的图像。我使用 SpringBoot + Maven ,它会自动从资源中添加公共文件夹;图像的完整路径为/src/main/recources/public/img/cdcb.png
结果您可以获得可点击的图像,就像您在下面看到的那样: