Skip to content

Commit

Permalink
✨ Feat[#10]: Swagger에 로컬 및 배포 서버 Url 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kduoh99 committed Nov 21, 2024
1 parent 54de5c2 commit f9c346b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/com/groom/swipo/global/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.groom.swipo.global.config;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -8,10 +11,17 @@
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 io.swagger.v3.oas.models.servers.Server;

@Configuration
public class SwaggerConfig {

@Value("${app.local-url}")
private String localUrl;

@Value("${app.prod-url}")
private String prodUrl;

private Info apiInfo() {
return new Info()
.version("v1.0.0")
Expand All @@ -23,6 +33,14 @@ private Info apiInfo() {
public OpenAPI openAPI() {
String authHeader = "Authorization";

Server localServer = new Server();
localServer.description("Local Server")
.url(localUrl);

Server prodServer = new Server();
prodServer.description("Production Server")
.url(prodUrl);

return new OpenAPI()
.info(apiInfo())
.addSecurityItem(new SecurityRequirement().addList(authHeader))
Expand All @@ -31,6 +49,7 @@ public OpenAPI openAPI() {
.name(authHeader)
.type(SecurityScheme.Type.HTTP)
.scheme("Bearer")
.bearerFormat("JWT")));
.bearerFormat("accessToken")))
.servers(Arrays.asList(localServer, prodServer));
}
}
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ sms:
api-secret: ${sms.api-secret}
sender: ${sms.sender}
provider: https://api.coolsms.co.kr

app:
local-url: ${app.local-url}
prod-url: ${app.prod-url}

0 comments on commit f9c346b

Please sign in to comment.