ECS-CMD/YuNan-system-start/src/main/java/com/yunan/config/SwaggerConfig.java
2024-11-09 13:22:03 +08:00

107 lines
3.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.yunan.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.oas.annotations.EnableOpenApi;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.service.Contact;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//
//import java.util.Collections;
//
//
//@Configuration //声明配置类
//@EnableOpenApi //开启swagger支持
//public class SwaggerConfig {
//
// /**
// * Docket类是Swagger的配置类要自定义修改Swagger的默认配置信息我们需要覆盖该对象
// *
// * @return
// */
// @Bean
// public Docket docket() {
// //1.以OAS_30标准构建Docket配置类
// return new Docket(DocumentationType.OAS_30)
// //2.配置Swagger接口文档基本信息apiInfo
// .apiInfo(apiInfo())
// //3.select方法开启配置扫描接口的Builder
// .select()
// //4.指定要扫描/维护接口文档的包(否则就全部扫描)
// .apis(RequestHandlerSelectors.basePackage("com.yunan.controller"))
// //5.路径过滤该Docket-UI展示时只展示指定路径下的接口文档(any表示都展示)
// .paths(PathSelectors.any())
// .build();
// }
//
// /**
// * 配置 Swagger 接口文档的基本信息
// *
// * @return
// */
// private ApiInfo apiInfo() {
// return new ApiInfoBuilder()
// //1.接口文档标题
// .title("SpringBoot整合Swagger")
// //2.接口文档描述内容
// .description("这里是SpringBoot整合Swagger的详细信息......,包括...")
// //3.项目文档迭代版本
// .version("9.0")
// //4.主要联系人信息姓名name个人主页url邮箱email
//// .contact(new Contact("阿安", "www.baidu.com", "3194726156@qq.com"))
// //5.相关许可证信息
//// .license("The CSDN License")
// //6.相关许可证链接
//// .licenseUrl("www.baidu.com")
// //7.返回构建的ApiInfo对象
// .build();
// }
//}
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.Collections;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.yunan.controller")) // 替换为你的包名
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo(
"API标题", // 标题
"API描述", // 描述
"版本信息", // 版本
"服务条款URL", // 服务条款URL
new Contact("联系人姓名", "网址", "邮箱"), // 联系人信息
"许可证", // 许可证
"许可证URL", // 许可证URL
Collections.emptyList() // 扩展列表
);
}
}