Skip to content

Commit

Permalink
feat: 스웨거 그룹화 (#1138)
Browse files Browse the repository at this point in the history
* chore: swagger 패키지 생성 및 클래스 이동

* feat: 비즈니스팀 API 그룹화

* chore: 비즈니스 API 추가

* feat: 캠퍼스팀 API 그룹화

* feat: 유저팀 API 그룹화

* feat: ABTEST API 그룹화

* feat: BCSD API 그룹화

* chore: 비즈니스팀 API 추가

* feat: 어드민 API 그룹화

* chore: 유저팀 API 추가

* feat: 로그인 API 그룹화 및 그룹 이름 변경

* refactor: 패키지 경로 enum화

* refactor: 중복 코드 메소드화

* refactor: 그룹 스웨거 파일 분할

* chore: 미사용 import 삭제

* chore: 메소드 명 변경

* chore: 리뷰 반영
  • Loading branch information
Soundbar91 authored and duehee committed Dec 30, 2024
1 parent 0025f00 commit 1026bd4
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package in.koreatech.koin.global.config;
package in.koreatech.koin.global.config.swagger;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -37,7 +37,6 @@ public OpenAPI openAPI() {
server.setUrl(serverUrl);
return new OpenAPI()
.openapi("3.1.0")
.components(new Components())
.info(apiInfo())
.addSecurityItem(securityRequirement)
.components(components)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package in.koreatech.koin.global.config.swagger;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerGroupConfig {

@Bean
public GroupedOpenApi loginApi() {
String[] apiPath = new String[] {
"/**/login"
};

return GroupedOpenApi.builder()
.group("0. Login API")
.pathsToMatch(apiPath)
.build();
}

@Bean
public GroupedOpenApi adminApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.admin"
};

return createGroupedOpenApi("1. Admin API", packagesPath);
}

@Bean
public GroupedOpenApi businessApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.domain.owner",
"in.koreatech.koin.domain.benefit",
"in.koreatech.koin.domain.ownershop",
"in.koreatech.koin.domain.shop",
"in.koreatech.koin.domain.land"
};

return createGroupedOpenApi("2. Business API", packagesPath);
}

@Bean
public GroupedOpenApi campusApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.domain.bus",
"in.koreatech.koin.domain.community",
"in.koreatech.koin.domain.coop",
"in.koreatech.koin.domain.coopshop",
"in.koreatech.koin.domain.dining"
};

return createGroupedOpenApi("3. Campus API", packagesPath);
}

@Bean
public GroupedOpenApi userApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.domain.user",
"in.koreatech.koin.domain.student",
"in.koreatech.koin.domain.timetable",
"in.koreatech.koin.domain.timetableV2"
};

return createGroupedOpenApi("4. User API", packagesPath);
}

@Bean
public GroupedOpenApi abtestApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.admin.abtest"
};

return createGroupedOpenApi("5. abTest API", packagesPath);
}

@Bean
public GroupedOpenApi bcsdApi() {
String[] packagesPath = new String[] {
"in.koreatech.koin.domain.activity",
"in.koreatech.koin.domain.dept",
"in.koreatech.koin.domain.kakao",
"in.koreatech.koin.domain.member",
"in.koreatech.koin.domain.version"
};

return createGroupedOpenApi("6. bcsd API", packagesPath);
}

private GroupedOpenApi createGroupedOpenApi(String groupName, String[] packagesPath) {
return GroupedOpenApi.builder()
.group(groupName)
.packagesToScan(packagesPath)
.build();
}
}

0 comments on commit 1026bd4

Please sign in to comment.