Merge branch 'be/fix/swagger-https' into 'be/develop'

Fix: Swagger 요청 실패 에러 해결 - S11P21S002-188

See merge request s11-s-project/S11P21S002!88
This commit is contained in:
김용수 2024-09-19 13:56:01 +09:00
commit 53a455fc5f

View File

@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityScheme; import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import org.springdoc.core.customizers.OperationCustomizer; import org.springdoc.core.customizers.OperationCustomizer;
import org.springdoc.core.models.GroupedOpenApi; import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -16,7 +18,11 @@ import org.springframework.context.annotation.Configuration;
title = "auto labeling API", title = "auto labeling API",
description = "auto labeling API 목록입니다.", description = "auto labeling API 목록입니다.",
version = "v1.0" version = "v1.0"
) ),
servers = {
@Server(url = "https://worlabel.site", description = "Worlabel Server URL"),
@Server(url = "https://j11s002.p.ssafy.io", description = "J11S002 Server URL")
}
) )
@SecurityScheme( @SecurityScheme(
name = "Authorization", name = "Authorization",
@ -51,8 +57,9 @@ public class SwaggerConfig {
return GroupedOpenApi.builder() return GroupedOpenApi.builder()
.group("token 필요 API") .group("token 필요 API")
.pathsToExclude(noRequiredTokenApi) .pathsToExclude(noRequiredTokenApi)
.addOperationCustomizer(operationCustomizer) .addOperationCustomizer((operation, handlerMethod) ->
operation.addSecurityItem(new SecurityRequirement().addList("Authorization"))
)
.build(); .build();
} }
} }