记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
61e7d54a
Commit
61e7d54a
authored
Aug 13, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整Swagger.API响应状态;
parent
0f16eee2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
+26
-2
Swagger2Config.java
...a/com/liquidnet/common/swagger/config/Swagger2Config.java
+26
-2
No files found.
liquidnet-bus-common/liquidnet-common-swagger/src/main/java/com/liquidnet/common/swagger/config/Swagger2Config.java
View file @
61e7d54a
...
...
@@ -6,24 +6,48 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMethod
;
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.service.ResponseMessage
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
@EnableSwagger2WebMvc
public
class
Swagger2Config
{
@Autowired
private
Environment
environment
;
List
<
ResponseMessage
>
responseMessageList
=
new
ArrayList
<
ResponseMessage
>()
{
private
static
final
long
serialVersionUID
=
-
5089595359417116101L
;
{
// add(
// new ResponseMessageBuilder().code(HttpStatus.INTERNAL_SERVER_ERROR.value()).message(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase())
// .responseModel(new ModelRef(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()))
// .build()
// );
}
};
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
globalResponseMessage
(
RequestMethod
.
GET
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
HEAD
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
POST
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
PUT
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
PATCH
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
DELETE
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
OPTIONS
,
responseMessageList
)
.
globalResponseMessage
(
RequestMethod
.
TRACE
,
responseMessageList
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
withMethodAnnotation
(
ApiOperation
.
class
))
...
...
@@ -36,9 +60,9 @@ public class Swagger2Config {
return
new
ApiInfoBuilder
()
.
title
((
StringUtils
.
isEmpty
(
appName
)
?
"service-xxx"
:
appName
.
substring
(
10
))
+
" APIs"
)
.
description
(
appName
)
.
contact
(
new
Contact
(
"lightnet"
,
""
,
"**@
lightnet.io
"
))
.
contact
(
new
Contact
(
"lightnet"
,
""
,
"**@
zhengzai.tv
"
))
.
version
(
"all"
)
.
termsOfServiceUrl
(
"xxx.
xxx.
xxx"
)
.
termsOfServiceUrl
(
"xxx.
zhengzai.tv/
xxx"
)
.
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