Skip to content

Commit

Permalink
faet: set swagger route
Browse files Browse the repository at this point in the history
  • Loading branch information
GitJIHO committed Nov 14, 2024
1 parent 769cafe commit 34cb7a1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/gdg/kkia/common/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,29 @@
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;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;

@Configuration
public class SwaggerConfig {
private static final String LOCAL_SERVER_URL = "http://localhost:8080";
private static final String PROD_SERVER_URL = "http://kkia.backapi.site:8100";
private final Environment environment;

public SwaggerConfig(Environment environment) {
this.environment = environment;
}

@Bean
public OpenAPI openAPI() {
String serverUrl = LOCAL_SERVER_URL;

if (environment.acceptsProfiles(Profiles.of("prod"))) {
serverUrl = PROD_SERVER_URL;
}

return new OpenAPI()
.components(new Components()
Expand All @@ -22,13 +37,14 @@ public OpenAPI openAPI() {
.scheme("bearer")
.bearerFormat("JWT")))
.info(apiInfo())
.addServersItem(new Server().url(serverUrl))
.addSecurityItem(new SecurityRequirement().addList("bearerAuth"));
}

private Info apiInfo() {
return new Info()
.title("77ㅑ 팀 API 명세서")
.description("화이팅!")
.version("0.0.1");
.version("0.0.2");
}
}

0 comments on commit 34cb7a1

Please sign in to comment.