Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-generator
Overview
Overview
Details
Activity
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
余保谷
ydl-generator
Commits
17081211
Commit
17081211
authored
Apr 15, 2019
by
flying-cattle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动端口获取
parent
6694fbfd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
53 deletions
+57
-53
SwaggerConfig.ftl
src/main/resources/freemarker/ftl/SwaggerConfig.ftl
+57
-53
No files found.
src/main/resources/freemarker/ftl/SwaggerConfig.ftl
View file @
17081211
/**
/**
*
@
filename
:${
entityName
}
Controller
${
createTime
}
*
@
filename
:${
entityName
}
Controller
${
createTime
}
*
@
project
${
project
}
${
version
}
*
@
project
${
project
}
${
version
}
*
Copyright
(
c
)
2020
${
author
}
Co
.
Ltd
.
*
Copyright
(
c
)
2020
${
author
}
Co
.
Ltd
.
*
All
right
reserved
.
*
All
right
reserved
.
*/
*/
package
${
swaggerConfigUrl
};
package
${
swaggerConfigUrl
};
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
org
.
springframework
.
context
.
annotation
.
Bean
;
import
springfox
.
documentation
.
builders
.
ApiInfoBuilder
;
import
org
.
springframework
.
context
.
annotation
.
Configuration
;
import
springfox
.
documentation
.
builders
.
PathSelectors
;
import
springfox
.
documentation
.
builders
.
ApiInfoBuilder
;
import
springfox
.
documentation
.
builders
.
RequestHandlerSelectors
;
import
springfox
.
documentation
.
builders
.
PathSelectors
;
import
springfox
.
documentation
.
service
.
ApiInfo
;
import
springfox
.
documentation
.
builders
.
RequestHandlerSelectors
;
import
springfox
.
documentation
.
spi
.
DocumentationType
;
import
springfox
.
documentation
.
service
.
ApiInfo
;
import
springfox
.
documentation
.
spring
.
web
.
plugins
.
Docket
;
import
springfox
.
documentation
.
spi
.
DocumentationType
;
import
springfox
.
documentation
.
swagger2
.
annotations
.
EnableSwagger2
;
import
springfox
.
documentation
.
spring
.
web
.
plugins
.
Docket
;
/**
import
springfox
.
documentation
.
swagger2
.
annotations
.
EnableSwagger2
;
*
Swagger
核心配置文件
/**
*
========================
*
Swagger
核心配置文件
*
@
author
${
author
}
*
========================
*
@
Date
${
createTime
}
*
@
author
${
author
}
*
========================
*
@
Date
${
createTime
}
*/
*
========================
@
Configuration
*/
@
EnableSwagger2
@
Configuration
public
class
SwaggerConfig
{
@
EnableSwagger2
public
class
SwaggerConfig
{
public
static
String
CONTROLLER_URL
=
"${controllerUrl}"
;
//
Swagger
扫描的接口路径
public
static
String
SWAGGER_TITLE
=
"API文档-${author}"
;
//
Swagger
接口文档标题
@
Value
(
"${server.port}"
)
public
static
String
SWAGGER_DESCRIPTION
=
"API文档"
;
//
Swagger
接口文档描述
private
static
String
port
;
public
static
String
SWAGGER_VERSION
=
"1.0"
;
//
Swagger
接口文档版本
public
static
String
SWAGGER_URL
=
"http://127.0.0.1:8080"
;
//
Swagger
项目服务的
URL
public
static
String
CONTROLLER_URL
=
"${controllerUrl}"
;
//
Swagger
扫描的接口路径
public
static
String
SWAGGER_TITLE
=
"API文档-${author}"
;
//
Swagger
接口文档标题
//
验证的页面
http
://
127.0.0.1
:
8080
/
swagger
-
ui
.
html
public
static
String
SWAGGER_DESCRIPTION
=
"API文档"
;
//
Swagger
接口文档描述
@
Bean
public
static
String
SWAGGER_VERSION
=
"1.0"
;
//
Swagger
接口文档版本
public
Docket
createRestApi
()
{
public
final
static
String
SWAGGER_URL
=
"http://127.0.0.1:"
+
port
;
//
Swagger
项目服务的
URL
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
//
验证的页面
http
://
127.0.0.1
:
8080
/
swagger
-
ui
.
html
.
select
()
@
Bean
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CONTROLLER_URL
))
public
Docket
createRestApi
()
{
.
paths
(
PathSelectors
.
any
())
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
build
();
.
apiInfo
(
apiInfo
())
}
.
select
()
private
ApiInfo
apiInfo
()
{
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CONTROLLER_URL
))
return
new
ApiInfoBuilder
()
.
paths
(
PathSelectors
.
any
())
.
title
(
SWAGGER_TITLE
)
.
build
();
.
description
(
SWAGGER_DESCRIPTION
)
}
.
termsOfServiceUrl
(
SWAGGER_URL
)
private
ApiInfo
apiInfo
()
{
.
version
(
SWAGGER_VERSION
)
return
new
ApiInfoBuilder
()
.
build
();
.
title
(
SWAGGER_TITLE
)
}
.
description
(
SWAGGER_DESCRIPTION
)
}
.
termsOfServiceUrl
(
SWAGGER_URL
)
.
version
(
SWAGGER_VERSION
)
.
build
();
}
}
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