update 优化 springdoc 配置鉴权头写死问题 增加持久化鉴权头配置
This commit is contained in:
parent
dd9ef8431b
commit
15f7d4dc47
@ -129,6 +129,10 @@ security:
|
||||
- /favicon.ico
|
||||
- /*/api-docs
|
||||
- /*/api-docs/**
|
||||
- /swagger-ui/**
|
||||
- /webjars/**
|
||||
- /swagger-ui.html
|
||||
- /doc.html
|
||||
# actuator 监控配置
|
||||
- /actuator
|
||||
- /actuator/**
|
||||
@ -202,6 +206,9 @@ swagger:
|
||||
name: ${sa-token.token-name}
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
# 持久化认证数据
|
||||
persistAuthorization: true
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
|
@ -23,6 +23,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Swagger 文档配置
|
||||
@ -51,8 +52,11 @@ public class SwaggerConfig {
|
||||
openApi.tags(swaggerProperties.getTags());
|
||||
openApi.paths(swaggerProperties.getPaths());
|
||||
openApi.components(swaggerProperties.getComponents());
|
||||
Set<String> keySet = swaggerProperties.getComponents().getSecuritySchemes().keySet();
|
||||
List<SecurityRequirement> list = new ArrayList<>();
|
||||
list.add(new SecurityRequirement().addList("apikey"));
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
keySet.forEach(securityRequirement::addList);
|
||||
list.add(securityRequirement);
|
||||
openApi.security(list);
|
||||
|
||||
return openApi;
|
||||
|
Loading…
x
Reference in New Issue
Block a user