Skip to content

Commit

Permalink
Refactor/api prefix 추가 (#81)
Browse files Browse the repository at this point in the history
* refactor: Swagger prefix 추가

* refactor: JSESSIONID 상수로 통일

* fix: test 프로퍼티에도 api prefix 정보 추가
  • Loading branch information
This2sho authored May 3, 2024
1 parent a6a072c commit b255da0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
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/}

0 comments on commit b255da0

Please sign in to comment.