From 19d7f3e74a67c7fd6e69942b79cc19e875eebda3 Mon Sep 17 00:00:00 2001 From: whz <6168830@qq.com> Date: Mon, 27 May 2024 15:48:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8api=E7=95=8C=E9=9D=A2=E4=B8=8A?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E5=A1=AB=E5=86=99jwt?= =?UTF-8?q?=E7=9A=84token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lk/paopao/conf/SwaggerConfig.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/com/lk/paopao/conf/SwaggerConfig.java 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