|
@@ -0,0 +1,63 @@
|
|
|
+package com.zzys.lightting.config;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.context.annotation.Profile;
|
|
|
+import springfox.documentation.builders.ApiInfoBuilder;
|
|
|
+import springfox.documentation.builders.ParameterBuilder;
|
|
|
+import springfox.documentation.builders.PathSelectors;
|
|
|
+import springfox.documentation.builders.RequestHandlerSelectors;
|
|
|
+import springfox.documentation.schema.ModelRef;
|
|
|
+import springfox.documentation.service.ApiInfo;
|
|
|
+import springfox.documentation.service.Parameter;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:knife4j配置信息
|
|
|
+ * @Author: mimang
|
|
|
+ * @Date: 2025/1/9
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+@EnableSwagger2WebMvc
|
|
|
+@Profile(value = "dev")
|
|
|
+public class Knife4jConfig {
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Docket adminApiConfig() {
|
|
|
+ List<Parameter> pars = new ArrayList<>();
|
|
|
+ ParameterBuilder tokenPar = new ParameterBuilder();
|
|
|
+ tokenPar.name("Authorization")
|
|
|
+ .description("用户token")
|
|
|
+ .defaultValue("")
|
|
|
+ .modelRef(new ModelRef("string"))
|
|
|
+ .parameterType("header")
|
|
|
+ .build();
|
|
|
+ pars.add(tokenPar.build());
|
|
|
+ //添加head参数end
|
|
|
+
|
|
|
+ Docket adminApi = new Docket(DocumentationType.SWAGGER_2)
|
|
|
+ .groupName("adminApi")
|
|
|
+ .apiInfo(adminApiInfo())
|
|
|
+ .select()
|
|
|
+ .apis(RequestHandlerSelectors.basePackage("com.zzys"))
|
|
|
+ .paths(PathSelectors.any())
|
|
|
+ //.paths(PathSelectors.regex("/admin/.*"))
|
|
|
+ .build()
|
|
|
+ .globalOperationParameters(pars);
|
|
|
+ return adminApi;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ApiInfo adminApiInfo() {
|
|
|
+
|
|
|
+ return new ApiInfoBuilder()
|
|
|
+ .title("后台权限管理系统-API文档")
|
|
|
+ .description("本文档描述了后台管理系统微服务接口定义")
|
|
|
+ .version("1.0")
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+}
|