Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
acb459a7
Commit
acb459a7
authored
Jun 04, 2020
by
Junling Bu
Browse files
chore: 引入swagger-bootstrap-ui
parent
b33db760
Changes
11
Hide whitespace changes
Inline
Side-by-side
deploy/litemall/application.yml
View file @
acb459a7
...
...
@@ -142,4 +142,7 @@ litemall:
endpoint
:
http://pd5cb6ulu.bkt.clouddn.com
accessKey
:
111111
secretKey
:
xxxxxx
bucketName
:
litemall
\ No newline at end of file
bucketName
:
litemall
swagger
:
production
:
true
\ No newline at end of file
doc/api.md
View file @
acb459a7
...
...
@@ -439,11 +439,26 @@ API应该存在版本控制,以保证兼容性。
造成代码不是很简洁。特别是具备代码属性的注解和Swagger文档注解混杂在一起,可能不是很好。
当然,本项目也简单地配置了Swagger(见
`WxSwagger2Configuration`
和
`AdminSwagger2Configuration`
),
在线Swagger文档链接:http://122.51.199.160:8080/swagger-ui.html
*
在线Swagger文档链接:http://122.51.199.160:8080/swagger-ui.html
*
本地Swagger文档链接:http://localhost:8080/swagger-ui.html
此外,也使用了swagger-bootstrap-ui对Swagger进一步增强了使用效果。
*
在线swagger-bootstrap-ui文档链接:http://122.51.199.160:8080/doc.html
*
本地swagger-bootstrap-ui文档链接:http://localhost:8080/doc.html
当然正如上文讨论,本项目不是很接受Swagger的理念,所以后端没有使用Swagger的相关文档注解,
这也导致了Swagger接口文档的不具可读性。如果开发者需要,可以自行在后端补充Swagger注解。
需要注意的是:
> 这里接口默认是公开的,因此项目一旦需要上线,请及时删除swagger和swagger-bootstrap-ui依赖和配置,
> 或者采取其他手段,防止接口对外暴露造成**安全隐患**。
例如
```
swagger:
production: false
```
## 2 商城API服务
### 2.1 安全服务
...
...
docker/litemall/application.yml
View file @
acb459a7
...
...
@@ -142,4 +142,7 @@ litemall:
endpoint
:
http://pd5cb6ulu.bkt.clouddn.com
accessKey
:
111111
secretKey
:
xxxxxx
bucketName
:
litemall
\ No newline at end of file
bucketName
:
litemall
swagger
:
production
:
true
\ No newline at end of file
litemall-admin-api/pom.xml
View file @
acb459a7
...
...
@@ -40,6 +40,11 @@
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-spring-boot-web-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
<version>
1.9.6
</version>
</dependency>
</dependencies>
<build>
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/config/AdminSwagger2Configuration.java
View file @
acb459a7
package
org.linlinjava.litemall.admin.config
;
import
com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
...
...
@@ -20,6 +22,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public
class
AdminSwagger2Configuration
{
@Bean
public
Docket
adminDocket
()
{
...
...
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/config/ShiroConfig.java
View file @
acb459a7
...
...
@@ -33,13 +33,7 @@ public class ShiroConfig {
filterChainDefinitionMap
.
put
(
"/admin/auth/401"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/admin/auth/index"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/admin/auth/403"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/admin/index/index"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/swagger-ui.html"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/swagger-resources"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/swagger-resources/configuration/security"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/swagger-resources/configuration/ui"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/v2/api-docs"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/webjars/springfox-swagger-ui/**"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/admin/index/*"
,
"anon"
);
filterChainDefinitionMap
.
put
(
"/admin/**"
,
"authc"
);
shiroFilterFactoryBean
.
setLoginUrl
(
"/admin/auth/401"
);
...
...
litemall-admin-api/src/main/resources/application.yml
View file @
acb459a7
...
...
@@ -13,4 +13,7 @@ logging:
org.springframework
:
ERROR
org.mybatis
:
ERROR
org.linlinjava.litemall.admin
:
DEBUG
org.linlinjava.litemall
:
ERROR
\ No newline at end of file
org.linlinjava.litemall
:
ERROR
swagger
:
production
:
false
\ No newline at end of file
litemall-all/src/main/resources/application.yml
View file @
acb459a7
...
...
@@ -16,4 +16,7 @@ server:
mime-types
:
application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
logging
:
config
:
classpath:logback-spring.xml
\ No newline at end of file
config
:
classpath:logback-spring.xml
swagger
:
production
:
false
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/config/WxSwagger2Configuration.java
View file @
acb459a7
package
org.linlinjava.litemall.wx.config
;
import
com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
...
...
@@ -20,6 +21,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public
class
WxSwagger2Configuration
{
@Bean
public
Docket
wxDocket
()
{
...
...
litemall-wx-api/src/main/resources/application.yml
View file @
acb459a7
...
...
@@ -13,4 +13,7 @@ logging:
org.springframework
:
ERROR
org.mybatis
:
ERROR
org.linlinjava.litemall.wx
:
DEBUG
org.linlinjava.litemall
:
ERROR
\ No newline at end of file
org.linlinjava.litemall
:
ERROR
swagger
:
production
:
false
\ No newline at end of file
pom.xml
View file @
acb459a7
...
...
@@ -159,14 +159,14 @@
<dependency>
<groupId>
com.github.xiaoymin
</groupId>
<artifactId>
swagger-bootstrap-ui
</artifactId>
<version>
1.9.
3
</version>
<version>
1.9.
6
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
25.1-jre
</version>
</dependency>
<dependency>
<groupId>
com.auth0
</groupId>
<artifactId>
java-jwt
</artifactId>
...
...
Write
Preview
Supports
Markdown
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