我有一个Spring项目正在运行。我想把swagger-2和这个项目结合起来。我已经成功地包含了所有必需的依赖项、bean和http://localhost:8000/AllergiesConditions/swagger-ui.html#/加载,但并不完全是我所需要的方式。
案例1:如果我将bean保存为这样的话:
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.app.allergiesConditions.controller"))
.paths(PathSelectors.regex("/AllergiesConditions/*"))
.build();
}Swagger-ui加载如下:

案例2:如果我将bean保存为这样的话:
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}Swagger-ui加载如下:

问题:我只想在我傲慢的ui中看到条件过敏-控制器(图2中的第3项)。为此,我应该在我的swaggerConfig bean中写什么??
注意:到目前为止,在案例1中,没有可加载控制器出现。所需的控制器位于包: com.app.allergiesConditions.controller中,我的示例API url类似于:http://localhost:8000/AllergiesConditions/api/v1/fetchConsumerDetails。
发布于 2018-01-04 07:39:07
我找到了答案:
下面的bean完成了这项工作:
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.app.allergiesConditions.controller"))
.paths(PathSelectors.any())
.build();
}https://stackoverflow.com/questions/48090517
复制相似问题