Skip to content

Commit

Permalink
docs: 기존 컨트롤러 swagger 문서 작성 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfer2442 committed May 3, 2024
1 parent d69505b commit 37df90b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/com/haedal/haedalweb/controller/JoinController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package com.haedal.haedalweb.controller;

import com.haedal.haedalweb.constants.ErrorCode;
import com.haedal.haedalweb.constants.SuccessCode;
import com.haedal.haedalweb.dto.JoinDTO;
import com.haedal.haedalweb.dto.SuccessResponse;
import com.haedal.haedalweb.swagger.ApiErrorCodeExamples;
import com.haedal.haedalweb.swagger.ApiSuccessCodeExample;
import com.haedal.haedalweb.swagger.ApiSuccessCodeExamples;
import com.haedal.haedalweb.util.ResponseUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -14,6 +21,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "회원가입 관련 API")
@RestController
@RequestMapping("/join")
public class JoinController {
Expand All @@ -23,13 +31,19 @@ public JoinController(JoinService joinService) {
this.joinService = joinService;
}

@Operation(summary = "회원가입")
@ApiSuccessCodeExample(SuccessCode.JOIN_SUCCESS)
@ApiErrorCodeExamples({ErrorCode.DUPLICATED_USER_ID, ErrorCode.DUPLICATED_STUDENT_NUMBER, ErrorCode.INVALID_PARAMETER})
@PostMapping
public ResponseEntity<SuccessResponse> resisterUser(@RequestBody @Valid JoinDTO joinDTO) {
joinService.createUserAccount(joinDTO);

return ResponseUtil.buildSuccessResponseEntity(SuccessCode.JOIN_SUCCESS);
}

@Operation(summary = "ID 중복확인")
@Parameter(name = "userId", description = "중복 확인할 ID")
@ApiSuccessCodeExamples({SuccessCode.UNIQUE_USER_ID, SuccessCode.DUPLICATED_USER_ID})
@GetMapping("/check-user-id")
public ResponseEntity<SuccessResponse> checkUserIdDuplicate(@RequestParam String userId) {
SuccessCode successCode = SuccessCode.UNIQUE_USER_ID;
Expand All @@ -40,6 +54,9 @@ public ResponseEntity<SuccessResponse> checkUserIdDuplicate(@RequestParam String
return ResponseUtil.buildSuccessResponseEntity(successCode);
}

@Operation(summary = "학번 중복확인")
@Parameter(name = "studentNumber", description = "중복 확인할 학번")
@ApiSuccessCodeExamples({SuccessCode.UNIQUE_STUDENT_NUMBER, SuccessCode.DUPLICATED_STUDENT_NUMBER})
@GetMapping("/check-student-number")
public ResponseEntity<SuccessResponse> checkStudentNumberDuplicate(@RequestParam Integer studentNumber) {
SuccessCode successCode = SuccessCode.UNIQUE_STUDENT_NUMBER;
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/haedal/haedalweb/controller/LoginController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.haedal.haedalweb.controller;

import com.haedal.haedalweb.constants.ErrorCode;
import com.haedal.haedalweb.constants.SuccessCode;
import com.haedal.haedalweb.dto.LoginDTO;
import com.haedal.haedalweb.swagger.ApiErrorCodeExamples;
import com.haedal.haedalweb.swagger.ApiSuccessCodeExample;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Tag(name = "로그인 관련 API")
@Controller
public class LoginController {

@Operation(summary = "로그인 API")
@ApiSuccessCodeExample(SuccessCode.LOGIN_SUCCESS)
@ApiErrorCodeExamples({ErrorCode.INVALID_LOGIN_CONTENTS_TYPE, ErrorCode.FAILED_LOGIN})
@PostMapping("/login")
public void signIn(@RequestBody LoginDTO loginDTO) {
}

@Operation(summary = "로그아웃 API")
@ApiSuccessCodeExample(SuccessCode.LOGOUT_SUCCESS)
@ApiErrorCodeExamples({ErrorCode.NULL_REFRESH_TOKEN, ErrorCode.INVALID_REFRESH_TOKEN, ErrorCode.EXPIRED_REFRESH_TOKEN})
@PostMapping("/logout")
public void signIn() {
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.haedal.haedalweb.controller;

import com.haedal.haedalweb.constants.ErrorCode;
import com.haedal.haedalweb.constants.SuccessCode;
import com.haedal.haedalweb.service.IssueService;
import com.haedal.haedalweb.swagger.ApiErrorCodeExamples;
import com.haedal.haedalweb.swagger.ApiSuccessCodeExample;
import com.haedal.haedalweb.util.ResponseUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "토큰 재발급")
@RequiredArgsConstructor
@RestController
public class ReissueController {
private final IssueService issueService;

@Operation(summary = "JWT 재발급")
@ApiSuccessCodeExample(SuccessCode.REISSUE_SUCCESS)
@ApiErrorCodeExamples({ErrorCode.NULL_REFRESH_TOKEN, ErrorCode.EXPIRED_REFRESH_TOKEN, ErrorCode.INVALID_REFRESH_TOKEN})
@PostMapping("/reissue")
public ResponseEntity<?> reissue(HttpServletRequest request, HttpServletResponse response) {
issueService.reissueToken(request, response);
Expand Down

0 comments on commit 37df90b

Please sign in to comment.