Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/api prefix 추가 #81

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.swagger.v3.oas.models.security.SecurityScheme.In;
import io.swagger.v3.oas.models.security.SecurityScheme.Type;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -19,14 +20,17 @@ public class SwaggerConfig {

private static final String JSESSIONID = "JSESSIONID";

@Value("${api-prefix}")
private String API_PREFIX;

@Bean
public OpenAPI openAPI() {
SecurityScheme auth = new SecurityScheme()
.type(Type.APIKEY).in(In.COOKIE).name(JSESSIONID);
SecurityRequirement securityRequirement = new SecurityRequirement().addList(JSESSIONID);

return new OpenAPI().addServersItem(new Server().url("/"))
.components(new Components().addSecuritySchemes("JSESSIONID", auth))
return new OpenAPI().addServersItem(new Server().url(API_PREFIX))
.components(new Components().addSecuritySchemes(JSESSIONID, auth))
.addSecurityItem(securityRequirement);
}
}
2 changes: 2 additions & 0 deletions app-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ authcode:
# Allow origin
cors:
allowedOrigins: ${ORIGIN:http://localhost:3000}

api-prefix: ${API_PREFIX:/api/}
8 changes: 2 additions & 6 deletions app-api/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ spring:
username: root
password: test

kakao:
key: test

seoul-public-parking-key: test
pusan-public-parking-key: test

authcode:
expired-time: 60

cors:
allowedOrigins: http://localhost:3000

api-prefix: ${API_PREFIX:/api/}
Loading