Skip to content

Commit

Permalink
swagger 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yujung7768903 committed Oct 22, 2024
1 parent e9ad1ba commit 7d73c8b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-redis')
implementation group: 'it.ozimov', name: 'embedded-redis', version: '0.7.2'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import com.moim.backend.domain.user.entity.Users;
import com.moim.backend.global.auth.Login;
import com.moim.backend.global.common.CustomResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -27,6 +30,7 @@ public class SpaceController {

// 모임 생성 API
@PostMapping("")
@Operation(summary = "모임 생성", description = "모임 생성")
public CustomResponseEntity<SpaceCreateResponse> createSpace(
@RequestBody @Valid SpaceCreateRequest request, @Login Users user
) {
Expand All @@ -35,6 +39,7 @@ public CustomResponseEntity<SpaceCreateResponse> createSpace(

// 모임 참여자 정보 리스트 조회 API
@GetMapping("")
@Operation(summary = "모임 참여자 정보 리스트 조회", description = "모임에 참여하고 있는 모임원 조회")
public CustomResponseEntity<SpaceDetailResponse> readParticipateSpaceByRegion(
@RequestParam Long groupId
) {
Expand All @@ -43,6 +48,7 @@ public CustomResponseEntity<SpaceDetailResponse> readParticipateSpaceByRegion(

// 모임 이름 수정 API
@PatchMapping("")
@Operation(summary = "모임 이름 수정", description = "모임 이름 수정")
public CustomResponseEntity<Void> updateSpaceName(
@RequestParam Long groupId,
@RequestBody @Valid SpaceNameUpdateRequest request, @Login Users user
Expand All @@ -52,6 +58,7 @@ public CustomResponseEntity<Void> updateSpaceName(

// 모임 참여 API
@PostMapping("/participate")
@Operation(summary = "모임 참여", description = "모임 참여")
public CustomResponseEntity<SpaceParticipateResponse> participateSpace(
@RequestBody @Valid SpaceParticipateRequest request, @Login Users user
) {
Expand All @@ -60,6 +67,7 @@ public CustomResponseEntity<SpaceParticipateResponse> participateSpace(

// 모임 삭제 API
@DeleteMapping("")
@Operation(summary = "모임 삭", description = "모임 삭제")
public CustomResponseEntity<Void> deleteSpace(
@RequestParam Long groupId, @Login Users user
) {
Expand All @@ -68,6 +76,10 @@ public CustomResponseEntity<Void> deleteSpace(

// 내 참여 정보 조회
@GetMapping("/user")
@Operation(summary = "내 참여 정보 조회", description = "내 참여 정보 조회")
@Parameters({
@Parameter(name = "groupId", description = "스페이스 아이디", example = "8")
})
public CustomResponseEntity<SpaceParticipationsResponse> getParticipationDetail(
@RequestParam Long groupId, @Login Users user
) {
Expand All @@ -77,6 +89,7 @@ public CustomResponseEntity<SpaceParticipationsResponse> getParticipationDetail(

// 내 참여 정보 수정 API
@PatchMapping("/participate")
@Operation(summary = "내 참여 정보 수정", description = "내 참여 정보 수정")
public CustomResponseEntity<SpaceParticipateUpdateResponse> participateUpdate(
@RequestBody @Valid SpaceParticipateUpdateRequest request, @Login Users user
) {
Expand All @@ -85,6 +98,7 @@ public CustomResponseEntity<SpaceParticipateUpdateResponse> participateUpdate(

// 모임 나가기 API
@DeleteMapping("/participate")
@Operation(summary = "모임 나가기", description = "모임 나가기")
public CustomResponseEntity<SpaceExitResponse> participateExit(
@RequestParam Long participateId, @Login Users user
) {
Expand All @@ -93,6 +107,7 @@ public CustomResponseEntity<SpaceExitResponse> participateExit(

// 모임 전체 나가기 API
@DeleteMapping("/participate/all")
@Operation(summary = "모임 전체 나가기", description = "모임 전체 나가기")
public CustomResponseEntity<Void> allParticipateExit(
@Login Users user
) {
Expand All @@ -101,6 +116,7 @@ public CustomResponseEntity<Void> allParticipateExit(

// 모임원 내보내기 API
@DeleteMapping("/participate/removal")
@Operation(summary = "모임원 내보내기", description = "모임원 내보내기")
public CustomResponseEntity<Void> participateRemoval(
@RequestParam Long participateId, @Login Users user
) {
Expand All @@ -109,6 +125,7 @@ public CustomResponseEntity<Void> participateRemoval(

// 모임 추천 역(랜드마크) 조회하기 API
@GetMapping("/best-region")
@Operation(summary = "모임 추천 지역 조회", description = "중간 지역 추천")
public CustomResponseEntity<List<PlaceRouteResponse>> getBestRegion(
@RequestParam Long groupId
) {
Expand All @@ -117,6 +134,7 @@ public CustomResponseEntity<List<PlaceRouteResponse>> getBestRegion(

// 내 모임 확인하기 API
@GetMapping("/participate")
@Operation(summary = "내 모임 리스트 조회", description = "내가 참여하고 있는 모임 리스트")
public CustomResponseEntity<List<SpaceMyParticipateResponse>> getMyParticipate(
@Login Users user,
@RequestParam(required = false) String spaceName,
Expand All @@ -125,8 +143,9 @@ public CustomResponseEntity<List<SpaceMyParticipateResponse>> getMyParticipate(
return CustomResponseEntity.success(spaceService.getMyParticipate(user, spaceName, filter));
}

// 모임 장소 추천 조회 리스트 API
// 추천 모임 장소 리스트 조회 API
@GetMapping("/best-region/place")
@Operation(summary = "추천 모임 장소 리스트 조회", description = "추천 지역 근처 모임 장소 추천")
public CustomResponseEntity<List<SpacePlaceResponse>> keywordCentralizedMeetingSpot(
@RequestParam Double x,
@RequestParam Double y,
Expand All @@ -138,6 +157,7 @@ public CustomResponseEntity<List<SpacePlaceResponse>> keywordCentralizedMeetingS

// 닉네임 유효성 체크
@GetMapping("/nickname")
@Operation(summary = "닉네임 유효성 체크", description = "스페이스 내에 동일한 닉네임이 있는지 중복 체크")
public CustomResponseEntity<NicknameValidationResponse> checkNicknameValidation(
@RequestParam Long groupId,
@RequestParam String nickname
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/moim/backend/global/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.moim.backend.global.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
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 org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
String jwt = "JWT";
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwt);
Components components = new Components().addSecuritySchemes(jwt, new SecurityScheme()
.name(jwt)
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")
);
return new OpenAPI()
.components(new Components())
.info(apiInfo())
.addSecurityItem(securityRequirement)
.components(components);
}
private Info apiInfo() {
return new Info()
.title("모이닷") // API의 제목
.description("모임 관리 서비스") // API에 대한 설명
.version("1.0.0"); // API의 버전
}
}

0 comments on commit 7d73c8b

Please sign in to comment.