Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
30540ac4
Commit
30540ac4
authored
Aug 20, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
23786adc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
SwaggerHelper.java
.../main/java/com/yanzuoguang/util/helper/SwaggerHelper.java
+61
-0
pom.xml
yzg-util-cloud/pom.xml
+37
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/SwaggerHelper.java
0 → 100644
View file @
30540ac4
package
com
.
yanzuoguang
.
util
.
helper
;
import
com.google.common.base.Function
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Predicate
;
import
springfox.documentation.RequestHandler
;
/**
* API文件生成工具类
*
* @author 颜佐光
*/
public
class
SwaggerHelper
{
/**
* Predicate that matches RequestHandler with given base package name for the class of the handler method.
* This predicate includes all request handlers matching the provided basePackage
*
* @param basePackage - base package of the classes
* @return this
*/
public
static
Predicate
<
RequestHandler
>
basePackage
(
String
...
basePackage
)
{
return
new
Predicate
<
RequestHandler
>()
{
@Override
public
boolean
apply
(
RequestHandler
input
)
{
return
declaringClass
(
input
).
transform
(
handlerPackage
(
basePackage
)).
or
(
true
);
}
};
}
/**
* 处理包路径配置规则,支持多路径扫描匹配以逗号隔开
*
* @param basePackage 扫描包路径
* @return Function
*/
private
static
Function
<
Class
<?>,
Boolean
>
handlerPackage
(
String
...
basePackage
)
{
return
new
Function
<
Class
<?>,
Boolean
>()
{
@Override
public
Boolean
apply
(
Class
<?>
input
)
{
for
(
String
strPackage
:
basePackage
)
{
boolean
isMatch
=
input
.
getPackage
().
getName
().
startsWith
(
strPackage
);
if
(
isMatch
)
{
return
true
;
}
}
return
false
;
}
};
}
/**
* @param input RequestHandler
* @return Optional
*/
private
static
Optional
<?
extends
Class
<?>>
declaringClass
(
RequestHandler
input
)
{
return
Optional
.
fromNullable
(
input
.
declaringClass
());
}
}
yzg-util-cloud/pom.xml
View file @
30540ac4
...
...
@@ -30,6 +30,12 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
...
...
@@ -46,27 +52,57 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- HTTP请求组件 -->
...
...
@@ -74,6 +110,7 @@
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment