Skip to content

1.3.0.RELEASE #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

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

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

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

Expand All @@ -23,7 +26,7 @@
<dependency>
<groupId>com.didispace</groupId>
<artifactId>spring-boot-starter-swagger</artifactId>
<version>1.2.0.RELEASE</version>
<version>1.3.0.RELEASE</version>
</dependency>
```

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

> host属性从1.3.0.RELEASE开始支持

### Path规则说明

`swagger.base-path`和`swagger.exclude-path`使用ANT规则配置。
Expand Down Expand Up @@ -132,7 +138,7 @@ swagger.exclude-path=/ops/**, /error
```properties
swagger.docket.aaa.title=group-a
swagger.docket.aaa.description=Starter for swagger 2.x
swagger.docket.aaa.version=1.2.0.RELEASE
swagger.docket.aaa.version=1.3.0.RELEASE
swagger.docket.aaa.termsOfServiceUrl=https://gitee.com/didispace/spring-boot-starter-swagger
swagger.docket.aaa.contact.name=zhaiyongchao
swagger.docket.aaa.contact.url=http://spring4all.com/
Expand All @@ -144,3 +150,21 @@ swagger.docket.bbb.basePackage=com.yonghui
```

说明:默认配置与分组配置可以一起使用。在分组配置中没有配置的内容将使用默认配置替代,所以默认配置可以作为分组配置公共部分属性的配置。

### JSR-303校验注解支持

支持对JSR-303校验注解的展示,如下图所示:

![JSR-303校验展示](https://github.com/dyc87112/spring-boot-starter-swagger/blob/master/images/jsr-303.png)

目前共支持以下几个注解:

- `@NotNull`
- `@Max、@Min`
- `@Size`
- `@Pattern`

## 贡献者

- [程序猿DD-翟永超](https://github.com/dyc87112/)
- [小火](https://renlulu.github.io/)
Binary file added images/jsr-303.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.didispace</groupId>
<artifactId>spring-boot-starter-swagger</artifactId>
<version>1.2.0.RELEASE</version>
<version>1.3.0.RELEASE</version>

<name>spring-boot-starter-swagger</name>
<url>https://github.com/dyc87112/spring-boot-starter-swagger</url>
Expand Down Expand Up @@ -38,6 +38,11 @@
<email>dyc87112@qq.com</email>
<organization>http://didispace.com</organization>
</developer>
<developer>
<name>小火</name>
<email>xiaohuo200@gmail.com</email>
<organization>https://renlulu.github.io/</organization>
</developer>
</developers>

<properties>
Expand Down Expand Up @@ -68,6 +73,11 @@
<artifactId>springfox-swagger2</artifactId>
<version>${version.swagger}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${version.swagger}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/didispace/swagger/EnableSwagger2Doc.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.didispace.swagger;

import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.lang.annotation.*;
Expand All @@ -15,7 +16,7 @@
@Documented
@Inherited
@EnableSwagger2
@Import(SwaggerAutoConfiguration.class)
@Import({SwaggerAutoConfiguration.class, BeanValidatorPluginsConfiguration.class})
public @interface EnableSwagger2Doc {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public List<Docket> createRestApi(SwaggerProperties swaggerProperties) {
}

Docket docket = new Docket(DocumentationType.SWAGGER_2)
.host(swaggerProperties.getHost())
.apiInfo(apiInfo)
.select()
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
Expand Down Expand Up @@ -126,6 +127,7 @@ public List<Docket> createRestApi(SwaggerProperties swaggerProperties) {
}

Docket docket = new Docket(DocumentationType.SWAGGER_2)
.host(swaggerProperties.getHost())
.apiInfo(apiInfo)
.groupName(groupName)
.select()
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/didispace/swagger/SwaggerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class SwaggerProperties {
/**分组文档**/
private Map<String, DocketInfo> docket = new LinkedHashMap<>();

/**host信息**/
private String host = "";

@Data
@NoArgsConstructor
public static class DocketInfo {
Expand Down