Swagger使用起来简单方便,几乎所有的API接口文档都采用swagger了。使用示例:http://www.cnblogs.com/woshimrf/p/swagger.html, 现在开发中可以参考文档,但生产环境并不想暴露出去。
只要在不同环境中配置是否启用就可以了。
@Value("${swagger.enable}")
private boolean enableSwagger;
@Bean
public Docket customImplementation(){
return new Docket(SWAGGER_2)
.apiInfo(apiInfo())
.enable(enableSwagger) //<--- Flag to enable or disable possibly loaded using a property file
.includePatterns(".*pet.*");
}
然后,我想在dev和test环境中启用,直接在配置文件中添加配置:
swagger:
enable: true
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有