官方网站的资料做证据,网站响应式设计,做网站按页面收费,晋城网络公司做网站的项目简介
该项目主要利用Spring Boot的自动化配置特性来实现快速的将swagger2引入spring boot应用来生成API文档#xff0c;简化原生使用swagger2的整合代码。
GitHub#xff1a;https://github.com/dyc87112/spring-boot-starter-swagger码云#xff1a;http://git.oschi…项目简介
该项目主要利用Spring Boot的自动化配置特性来实现快速的将swagger2引入spring boot应用来生成API文档简化原生使用swagger2的整合代码。
GitHubhttps://github.com/dyc87112/spring-boot-starter-swagger码云http://git.oschina.net/didispace/spring-boot-starter-swagger博客http://blog.didispace.com
小工具一枚欢迎使用和Star支持如使用过程中碰到问题可以提出Issue我会尽力完善该Starter
版本基础
Spring Boot1.5.xSwagger2.7.x
如何使用
在该项目的帮助下我们的Spring Boot可以轻松的引入swagger2主需要做下面两个步骤
在pom.xml中引入依赖
dependency groupIdcom.didispace/groupId artifactIdspring-boot-starter-swagger/artifactId version1.1.0.RELEASE/version/dependency在应用主类中增加EnableSwagger2Doc注解
EnableSwagger2DocSpringBootApplicationpublic class Bootstrap { public static void main(String[] args) { SpringApplication.run(Bootstrap.class, args); }}默认情况下就能产生所有当前Spring MVC加载的请求映射文档。
参数配置
更细致的配置内容参考如下
配置示例
swagger.titlespring-boot-starter-swaggerswagger.descriptionStarter for swagger 2.xswagger.version1.1.0.RELEASEswagger.licenseApache License, Version 2.0swagger.licenseUrlhttps://www.apache.org/licenses/LICENSE-2.0.htmlswagger.termsOfServiceUrlhttps://github.com/dyc87112/spring-boot-starter-swaggerswagger.contact.name程序猿DDswagger.contact.urlhttp://blog.didispace.comswagger.contact.emaildyc87112qq.comswagger.base-packagecom.didispaceswagger.base-path/**swagger.exclude-path/error, /ops/**配置说明
swagger.title标题swagger.description描述swagger.version版本swagger.license许可证swagger.licenseUrl许可证URLswagger.termsOfServiceUrl服务条款URLswagger.contact.name维护人swagger.contact.url维护人URLswagger.contact.email维护人emailswagger.base-packageswagger扫描的基础包默认全扫描swagger.base-path需要处理的基础URL规则默认/**swagger.exclude-path需要排除的URL规则默认空
Path规则说明
swagger.base-path和swagger.exclude-path使用ANT规则配置。
我们可以使用swagger.base-path来指定所有需要生成文档的请求路径基础规则然后再利用swagger.exclude-path来剔除部分我们不需要的。
比如通常我们可以这样设置
management.context-path/opsswagger.base-path/**swagger.exclude-path/ops/**, /error上面的设置将解析所有除了/ops/开始以及spring boot自带/error请求路径。
其中exclude-path可以配合management.context-path/ops设置的spring boot actuator的context-path来排除所有监控端点。