diff --git a/src/main/java/com/lk/paopao/conf/SwaggerConfig.java b/src/main/java/com/lk/paopao/conf/SwaggerConfig.java new file mode 100644 index 0000000..10ea25f --- /dev/null +++ b/src/main/java/com/lk/paopao/conf/SwaggerConfig.java @@ -0,0 +1,35 @@ +package com.lk.paopao.conf; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfig { + + @Bean + public OpenAPI customize() { + Components components = new Components(); + + SecurityScheme scheme = new SecurityScheme() + .name("bearerAuth") + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT"); + + components.addSecuritySchemes("bearerAuth", scheme); + + return new OpenAPI(). + components(components) + .addSecurityItem(new SecurityRequirement().addList("bearerAuth")) + .info(new Info() + .title("PaoPao API") + .description("PaoPao Restful API 接口测试") + .version("v1")); + } + +} \ No newline at end of file