简体   繁体   English

如何从 Swagger UI 中删除 controller 列表

[英]How to remove controller list from Swagger UI

I'm using springfox-swagger-ui 2.8.0 which ships with Swagger UI 3.7.0.我正在使用 Swagger UI 3.7.0 附带的 springfox-swagger-ui 2.8.0。

I want to get rid of the controller list in front of the api documentation page, pretty useless for me (every tab is empty).我想摆脱 api 文档页面前面的 controller 列表,这对我来说毫无用处(每个选项卡都是空的)。

I've already tried to annotate the controller class with @ApiIgnore, but of course this removes the rest api documentation as well, which I need.我已经尝试使用@ApiIgnore 注释 controller class,但当然这也删除了 rest api 文档,这是我需要的。

Basically, I want to remove this:基本上,我想删除这个:

要删除/隐藏的控制器列表

while keeping this:同时保持这个:

要保留的 REST api 文档

I digged through online docs, GitHub issues, StackOverflow questions, Google... nothing.我浏览了在线文档、GitHub 问题、StackOverflow 问题、谷歌……什么都没有。 Am I the only with this request?只有我有这个要求吗?

Add the attribute description to @Api : 将属性描述添加到@Api

For example: 例如:

@Api(value = "Test API Controller", produces = MediaType.APPLICATION_JSON_VALUE, tags = {"test-api-controller"}, description = "Testing API") 

on springfox v3.0 tried almost every annotations and finally在 springfox v3.0 上几乎尝试了所有注释,最后
@ApiIgnore annotation works. @ApiIgnore 注释有效。
Don't know why @Api(hidden=true) doesn't work.不知道为什么 @Api(hidden=true) 不起作用。

import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore
@Responsebody
public Object ...{}

在控制器上尝试此属性

[ApiExplorerSettings(IgnoreApi = true)]

I expected the hidden attribute will work but it doesn't.我预计hidden属性会起作用,但它不会。 I also tried to set description and also doesn't work.我也尝试设置description ,但也不起作用。

Another solution is to use the tag in the @Api can help you temporarily hide this rest-controllers list and categorize your APIs in different tags.另一种解决方案是使用@Api 中的tag可以帮助您暂时隐藏这个rest-controllers 列表并将您的API 分类到不同的标签中。

springfox api version 2.9.2 springfox api 版本 2.9.2

works with the below example by adding on a controller class通过添加控制器类来处理以下示例

@Api(value = "Test API Controller", tags = {"test-api-controller"}, description = "Testing API") @Api(value = "Test API Controller", tags = {"test-api-controller"}, description = "Testing API")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM