springboot升级到3后之前的knife4j配置就要变了一下了
com.github.xiaoymin knife4j-openapi3-jakarta-spring-boot-starter
4.1.0
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class Knife4jConfig { @Bean public OpenAPI springShopOpenAPI() { return new OpenAPI() // 接口文档标题 .info( new Info().title("接口文档") // 接口文档简介 .description("Knife4j OpenApi3的接口文档") // 接口文档版本 .version("v1.0") // 开发者联系方式 .contact(new Contact().name("").email("")) ); } }
@Tag(name = "首页")
public class HomeController {
controller方法上的注解
@Operation(summary = "获取xxx")
public Result
getxxx(){
@Data @Schema(name = "XXX") public class XXXVO{ @Id @Schema(description = "") private Integer id ; /** 父级id */ @Schema(description = "父级id") private Integer pid ; }