【发布时间】:2017-11-15 14:06:02
【问题描述】:
我正在使用 Springboot 自动配置,目前我所有的 Feign 端点都暴露在 swagger-ui 中。如何禁用此功能?
【问题讨论】:
标签: spring spring-boot swagger netflix-feign
我正在使用 Springboot 自动配置,目前我所有的 Feign 端点都暴露在 swagger-ui 中。如何禁用此功能?
【问题讨论】:
标签: spring spring-boot swagger netflix-feign
您可以在application.properties 中将其设置为:
endpoints.enabled=false
endpoints.health.enabled=true
endpoints.loggers.enabled=true
在你的情况下,它会是这样的
endpoints.feign.***=true
但这并没有禁用招摇,而是端点暴露自己。例如,对于 Swagger,您必须使用 @Api#hidden() 显式标记它们。
【讨论】:
到目前为止,不包含不相关端点的最佳方法是通过 Swagger Docker,例如
@Configuration
@EnableSwagger2
class SwaggerConf {
@Bean
Docket allApis() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("all")
.select().apis(RequestHandlerSelectors.basePackage("com.example.base"))
.build();
}
}
【讨论】:
对我有用的最简单的解决方案是将 @ApiIgnore 添加到 Feign 客户端
@ApiIgnore
@FeignClient()
public interface FeignApi {
}
【讨论】: