Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
EncryptedFileSystem
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhangshuang
EncryptedFileSystem
Commits
8d14ab48
提交
8d14ab48
authored
3月 23, 2020
作者:
LJJ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add swagger in efs-misc
上级
daacd14c
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
152 行增加
和
0 行删除
+152
-0
pom.xml
efs-misc/pom.xml
+52
-0
AutoDocument.java
.../src/main/java/com/zjty/efs/misc/config/AutoDocument.java
+23
-0
Swagger2Config.java
...rc/main/java/com/zjty/efs/misc/config/Swagger2Config.java
+77
-0
没有找到文件。
efs-misc/pom.xml
浏览文件 @
8d14ab48
...
...
@@ -11,5 +11,56 @@
<artifactId>
efs-misc
</artifactId>
<properties>
<swagger.version>
2.9.0
</swagger.version>
</properties>
<dependencies>
<!--swagger2 enable dependency-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-configuration-processor
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.caspar-chen
</groupId>
<artifactId>
swagger-ui-layer
</artifactId>
<version>
0.0.4
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-bean-validators
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--跳过测试插件-->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.20
</version>
<configuration>
<skipTests>
true
</skipTests>
<!--默认关掉单元测试 -->
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
efs-misc/src/main/java/com/zjty/efs/misc/config/AutoDocument.java
0 → 100644
浏览文件 @
8d14ab48
package
com
.
zjty
.
efs
.
misc
.
config
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.
ANNOTATION_TYPE
;
import
static
java
.
lang
.
annotation
.
ElementType
.
TYPE
;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
/**
* fusion-platform. swagger2 autoDocument interface for {@link Swagger2Config}
*
* @author : Matrix [xhyrzldf@gmail.com]
* 19-1-10 .
*/
@Target
({
TYPE
,
ANNOTATION_TYPE
})
@Retention
(
RUNTIME
)
@Documented
public
@interface
AutoDocument
{
String
value
()
default
""
;
}
efs-misc/src/main/java/com/zjty/efs/misc/config/Swagger2Config.java
0 → 100644
浏览文件 @
8d14ab48
package
com
.
zjty
.
efs
.
misc
.
config
;
import
com.google.common.collect.Sets
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* fusion-platform.
*
* @author : Matrix [xhyrzldf@gmail.com]
* 19-1-10 .
*/
@Configuration
@EnableSwagger2
public
class
Swagger2Config
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
produces
(
Sets
.
newHashSet
(
"application/json"
))
.
consumes
(
Sets
.
newHashSet
(
"application/json"
))
.
protocols
(
Sets
.
newHashSet
(
"http"
))
.
apiInfo
(
apiInfo
())
.
forCodeGeneration
(
true
)
.
useDefaultResponseMessages
(
true
)
// .globalResponseMessage(RequestMethod.GET, getResMsg())
.
select
()
// 指定controller存放的目录路径
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
AutoDocument
.
class
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
// 文档标题
.
title
(
"融合平台接口文档"
)
// 文档描述
.
description
(
"融合平台的接口文档与测试页面"
)
.
termsOfServiceUrl
(
"http://192.168.1.155:8080/fusion-group/fusion-platform"
)
.
version
(
"v1"
)
.
contact
(
new
Contact
(
"fusion-group"
,
"http://192.168.1.155:8080/fusion-group/fusion-platform"
,
"fusion-group@example.com"
))
.
build
();
}
// private ArrayList<ResponseMessage> getResMsg() {
// return newArrayList(new ResponseMessageBuilder()
// .code(500)
// .message("服务器内部发生了某种错误")
// .responseModel(new ModelRef("Error"))
// .build(),
// new ResponseMessageBuilder()
// .code(404)
// .message("用户发出的请求针对的是不存在的记录,服务器没有进行操作")
// .responseModel(new ModelRef("Exception"))
// .build(),
// new ResponseMessageBuilder()
// .code(406)
// .message("用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)")
// .responseModel(new ModelRef("Exception"))
// .build(),
// new ResponseMessageBuilder()
// .code(501)
// .message("不支持的HTTP请求,请检查HTTP TYPE与资源路径是否正确")
// .responseModel(new ModelRef("Exception"))
// .build());
// }
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论