mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-08 16:57:09 +08:00
style: 优化全局代码格式
This commit is contained in:
@@ -44,7 +44,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* API 文档自动配置
|
||||
*
|
||||
@@ -63,8 +62,9 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/");
|
||||
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/")
|
||||
.setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/")
|
||||
.setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,20 +73,16 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionProperties properties) {
|
||||
Info info = new Info()
|
||||
.title(String.format("%s %s", projectProperties.getName(), "API 文档"))
|
||||
.version(projectProperties.getVersion())
|
||||
.description(projectProperties.getDescription());
|
||||
Info info = new Info().title(String.format("%s %s", projectProperties.getName(), "API 文档"))
|
||||
.version(projectProperties.getVersion())
|
||||
.description(projectProperties.getDescription());
|
||||
ProjectProperties.Contact contact = projectProperties.getContact();
|
||||
if (null != contact) {
|
||||
info.contact(new Contact().name(contact.getName())
|
||||
.email(contact.getEmail())
|
||||
.url(contact.getUrl()));
|
||||
info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl()));
|
||||
}
|
||||
ProjectProperties.License license = projectProperties.getLicense();
|
||||
if (null != license) {
|
||||
info.license(new License().name(license.getName())
|
||||
.url(license.getUrl()));
|
||||
info.license(new License().name(license.getName()).url(license.getUrl()));
|
||||
}
|
||||
OpenAPI openAPI = new OpenAPI();
|
||||
openAPI.info(info);
|
||||
@@ -120,7 +116,10 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
||||
pathItem.readOperations().forEach(operation -> {
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
List<String> list = securitySchemeMap.values().stream().map(SecurityScheme::getName).toList();
|
||||
List<String> list = securitySchemeMap.values()
|
||||
.stream()
|
||||
.map(SecurityScheme::getName)
|
||||
.toList();
|
||||
list.forEach(securityRequirement::addList);
|
||||
operation.addSecurityItem(securityRequirement);
|
||||
});
|
||||
|
@@ -21,7 +21,6 @@ import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
|
||||
/**
|
||||
* API 文档扩展配置属性
|
||||
*
|
||||
|
Reference in New Issue
Block a user