|
|
@@ -2,11 +2,18 @@ package seecoder.devcloud.web.config;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+import springfox.boot.starter.autoconfigure.SpringfoxConfigurationProperties;
|
|
|
+import springfox.documentation.builders.ApiInfoBuilder;
|
|
|
import springfox.documentation.builders.PathSelectors;
|
|
|
+import springfox.documentation.oas.annotations.EnableOpenApi;
|
|
|
import springfox.documentation.service.ApiInfo;
|
|
|
import springfox.documentation.spi.DocumentationType;
|
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
|
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
|
|
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
|
@@ -17,22 +24,17 @@ import static springfox.documentation.builders.PathSelectors.regex;
|
|
|
* @date 2021/2/3
|
|
|
* @description:
|
|
|
*/
|
|
|
-public class SwaggerConfig {
|
|
|
+@Configuration
|
|
|
+@EnableOpenApi
|
|
|
+public class SwaggerConfig{
|
|
|
|
|
|
- @Value("${server.servlet-path}")
|
|
|
- private String pathMapping;
|
|
|
|
|
|
private ApiInfo initApiInfo() {
|
|
|
- ApiInfo apiInfo = new ApiInfo("seecoder devcloud项目 Platform API",//大标题
|
|
|
- initContextInfo(),//简单的描述
|
|
|
- "0.0.1",//版本
|
|
|
- "服务条款",
|
|
|
- "后台开发团队",//作者
|
|
|
- "The xxxxxxx License, Version",//todo 链接显示文字
|
|
|
- "http://www.xxxx.com"//todo 网站链接
|
|
|
- );
|
|
|
-
|
|
|
- return apiInfo;
|
|
|
+ return new ApiInfoBuilder()
|
|
|
+ .title("seecoder devcloud项目 Platform API")//大标题
|
|
|
+ .description(initContextInfo())//简单的描述
|
|
|
+ .version("0.0.1")//版本
|
|
|
+ .build();
|
|
|
}
|
|
|
|
|
|
private String initContextInfo() {
|
|
|
@@ -44,20 +46,13 @@ public class SwaggerConfig {
|
|
|
|
|
|
@Bean
|
|
|
public Docket restfulApi() {
|
|
|
- System.out.println("http://localhost:8080" + pathMapping + "/swagger-ui.html");
|
|
|
-
|
|
|
- return new Docket(DocumentationType.SWAGGER_2)
|
|
|
- .groupName("RestfulApi")
|
|
|
-// .genericModelSubstitutes(DeferredResult.class)
|
|
|
- .genericModelSubstitutes(ResponseEntity.class)
|
|
|
- .useDefaultResponseMessages(true)
|
|
|
- .forCodeGeneration(false)
|
|
|
- .pathMapping(pathMapping) // base,最终调用接口后会和paths拼接在一起
|
|
|
+ return new Docket(DocumentationType.OAS_30)
|
|
|
+ .apiInfo(initApiInfo())
|
|
|
.select()
|
|
|
//.paths(doFilteringRules())
|
|
|
.paths(PathSelectors.any())
|
|
|
- .build()
|
|
|
- .apiInfo(initApiInfo());
|
|
|
+ .build();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|