Skip to content

Commit 3f72fce

Browse files
author
程序猿DD-翟永超
authored
Merge pull request #11 from dyc87112/1.3.0
1.3.0.RELEASE
2 parents 05ea623 + f31c20e commit 3f72fce

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
该项目主要利用Spring Boot的自动化配置特性来实现快速的将swagger2引入spring boot应用来生成API文档,简化原生使用swagger2的整合代码。
44

5-
- GitHub:https://github.com/dyc87112/spring-boot-starter-swagger
6-
- 码云:http://git.oschina.net/didispace/spring-boot-starter-swagger
7-
- 博客:http://blog.didispace.com
5+
- 源码地址
6+
- GitHub:https://github.com/dyc87112/spring-boot-starter-swagger
7+
- 码云:https://gitee.com/didispace/spring-boot-starter-swagger
8+
- 使用样例:https://github.com/dyc87112/swagger-starter-demo
9+
- 我的博客:http://blog.didispace.com
10+
- 我们社区:http://spring4all.com
811

912
**小工具一枚,欢迎使用和Star支持,如使用过程中碰到问题,可以提出Issue,我会尽力完善该Starter**
1013

@@ -23,7 +26,7 @@
2326
<dependency>
2427
<groupId>com.didispace</groupId>
2528
<artifactId>spring-boot-starter-swagger</artifactId>
26-
<version>1.2.0.RELEASE</version>
29+
<version>1.3.0.RELEASE</version>
2730
</dependency>
2831
```
2932

@@ -52,7 +55,7 @@ public class Bootstrap {
5255
```properties
5356
swagger.title=spring-boot-starter-swagger
5457
swagger.description=Starter for swagger 2.x
55-
swagger.version=1.1.0.RELEASE
58+
swagger.version=1.3.0.RELEASE
5659
swagger.license=Apache License, Version 2.0
5760
swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
5861
swagger.termsOfServiceUrl=https://github.com/dyc87112/spring-boot-starter-swagger
@@ -81,8 +84,11 @@ swagger.exclude-path=/error, /ops/**
8184
- swagger.base-package=swagger扫描的基础包,默认:全扫描
8285
- swagger.base-path=需要处理的基础URL规则,默认:/**
8386
- swagger.exclude-path=需要排除的URL规则,默认:空
87+
- swagger.host=文档的host信息,默认:空
8488
```
8589

90+
> host属性从1.3.0.RELEASE开始支持
91+
8692
### Path规则说明
8793

8894
`swagger.base-path``swagger.exclude-path`使用ANT规则配置。
@@ -132,7 +138,7 @@ swagger.exclude-path=/ops/**, /error
132138
```properties
133139
swagger.docket.aaa.title=group-a
134140
swagger.docket.aaa.description=Starter for swagger 2.x
135-
swagger.docket.aaa.version=1.2.0.RELEASE
141+
swagger.docket.aaa.version=1.3.0.RELEASE
136142
swagger.docket.aaa.termsOfServiceUrl=https://gitee.com/didispace/spring-boot-starter-swagger
137143
swagger.docket.aaa.contact.name=zhaiyongchao
138144
swagger.docket.aaa.contact.url=http://spring4all.com/
@@ -144,3 +150,21 @@ swagger.docket.bbb.basePackage=com.yonghui
144150
```
145151

146152
说明:默认配置与分组配置可以一起使用。在分组配置中没有配置的内容将使用默认配置替代,所以默认配置可以作为分组配置公共部分属性的配置。
153+
154+
### JSR-303校验注解支持
155+
156+
支持对JSR-303校验注解的展示,如下图所示:
157+
158+
![JSR-303校验展示](https://github.com/dyc87112/spring-boot-starter-swagger/blob/master/images/jsr-303.png)
159+
160+
目前共支持以下几个注解:
161+
162+
- `@NotNull`
163+
- `@Max、@Min`
164+
- `@Size`
165+
- `@Pattern`
166+
167+
## 贡献者
168+
169+
- [程序猿DD-翟永超](https://github.com/dyc87112/)
170+
- [小火](https://renlulu.github.io/)

images/jsr-303.png

40.9 KB
Loading

pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.didispace</groupId>
88
<artifactId>spring-boot-starter-swagger</artifactId>
9-
<version>1.2.0.RELEASE</version>
9+
<version>1.3.0.RELEASE</version>
1010

1111
<name>spring-boot-starter-swagger</name>
1212
<url>https://github.com/dyc87112/spring-boot-starter-swagger</url>
@@ -38,6 +38,11 @@
3838
<email>dyc87112@qq.com</email>
3939
<organization>http://didispace.com</organization>
4040
</developer>
41+
<developer>
42+
<name>小火</name>
43+
<email>xiaohuo200@gmail.com</email>
44+
<organization>https://renlulu.github.io/</organization>
45+
</developer>
4146
</developers>
4247

4348
<properties>
@@ -68,6 +73,11 @@
6873
<artifactId>springfox-swagger2</artifactId>
6974
<version>${version.swagger}</version>
7075
</dependency>
76+
<dependency>
77+
<groupId>io.springfox</groupId>
78+
<artifactId>springfox-bean-validators</artifactId>
79+
<version>${version.swagger}</version>
80+
</dependency>
7181
<dependency>
7282
<groupId>org.projectlombok</groupId>
7383
<artifactId>lombok</artifactId>

src/main/java/com/didispace/swagger/EnableSwagger2Doc.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.didispace.swagger;
22

33
import org.springframework.context.annotation.Import;
4+
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
45
import springfox.documentation.swagger2.annotations.EnableSwagger2;
56

67
import java.lang.annotation.*;
@@ -15,7 +16,7 @@
1516
@Documented
1617
@Inherited
1718
@EnableSwagger2
18-
@Import(SwaggerAutoConfiguration.class)
19+
@Import({SwaggerAutoConfiguration.class, BeanValidatorPluginsConfiguration.class})
1920
public @interface EnableSwagger2Doc {
2021

2122

src/main/java/com/didispace/swagger/SwaggerAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public List<Docket> createRestApi(SwaggerProperties swaggerProperties) {
7373
}
7474

7575
Docket docket = new Docket(DocumentationType.SWAGGER_2)
76+
.host(swaggerProperties.getHost())
7677
.apiInfo(apiInfo)
7778
.select()
7879
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
@@ -126,6 +127,7 @@ public List<Docket> createRestApi(SwaggerProperties swaggerProperties) {
126127
}
127128

128129
Docket docket = new Docket(DocumentationType.SWAGGER_2)
130+
.host(swaggerProperties.getHost())
129131
.apiInfo(apiInfo)
130132
.groupName(groupName)
131133
.select()

src/main/java/com/didispace/swagger/SwaggerProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public class SwaggerProperties {
4444
/**分组文档**/
4545
private Map<String, DocketInfo> docket = new LinkedHashMap<>();
4646

47+
/**host信息**/
48+
private String host = "";
49+
4750
@Data
4851
@NoArgsConstructor
4952
public static class DocketInfo {

0 commit comments

Comments
 (0)