|
1 | 1 | package com.goormdari.domain.user.presentation; |
2 | 2 |
|
3 | 3 | import com.goormdari.domain.user.dto.request.AddUserRequest; |
| 4 | +import com.goormdari.domain.user.dto.response.FindCurrentStepResponse; |
4 | 5 | import com.goormdari.domain.user.dto.response.JwtResponse; |
5 | 6 | import com.goormdari.domain.user.dto.request.LoginRequest; |
6 | 7 | import com.goormdari.domain.user.service.UserService; |
7 | 8 |
|
| 9 | +import com.goormdari.global.payload.ErrorResponse; |
| 10 | +import io.swagger.v3.oas.annotations.Operation; |
| 11 | +import io.swagger.v3.oas.annotations.media.Content; |
| 12 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 13 | +import io.swagger.v3.oas.annotations.responses.ApiResponse; |
| 14 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 15 | +import io.swagger.v3.oas.annotations.tags.Tag; |
8 | 16 | import jakarta.validation.Valid; |
9 | 17 | import lombok.RequiredArgsConstructor; |
10 | 18 | import org.springframework.http.HttpStatus; |
|
14 | 22 | import org.springframework.web.bind.annotation.RequestMapping; |
15 | 23 | import org.springframework.web.bind.annotation.RestController; |
16 | 24 |
|
| 25 | +@Tag(name = "Authorization", description = "Authorization API") |
17 | 26 | @RestController |
18 | 27 | @RequestMapping("/auth") |
19 | 28 | @RequiredArgsConstructor |
20 | 29 | public class AuthController { |
21 | 30 |
|
22 | 31 | private final UserService userService; |
23 | 32 |
|
24 | | - /** |
25 | | - * 회원가입 후 JWT 토큰 발급 |
26 | | - * |
27 | | - * @param addUserRequest 회원가입 요청 데이터 |
28 | | - * @return JWT 응답 |
29 | | - */ |
| 33 | + @Operation(summary = "회원가입 후 로그인", description = "회원가입과 로그인을 수행합니다.") |
| 34 | + @ApiResponses(value = { |
| 35 | + @ApiResponse(responseCode = "200", description = "회원가입 성공 ", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = JwtResponse.class))}), |
| 36 | + @ApiResponse(responseCode = "400", description = "회원가입 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}), |
| 37 | + }) |
30 | 38 | @PostMapping("/signup") |
31 | 39 | public ResponseEntity<JwtResponse> registerUser(@Valid @RequestBody AddUserRequest addUserRequest) { |
32 | 40 | JwtResponse jwtResponse = userService.signupAndLogin(addUserRequest); |
33 | 41 | return ResponseEntity.status(HttpStatus.CREATED).body(jwtResponse); |
34 | 42 | } |
35 | 43 |
|
36 | | - /** |
37 | | - * 로그인 후 JWT 토큰 발급 |
38 | | - * |
39 | | - * @param loginRequest 로그인 요청 데이터 |
40 | | - * @return JWT 응답 |
41 | | - */ |
| 44 | + @Operation(summary = "로그인", description = "로그인을 수행합니다.") |
| 45 | + @ApiResponses(value = { |
| 46 | + @ApiResponse(responseCode = "200", description = "로그인 성공 ", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = JwtResponse.class))}), |
| 47 | + @ApiResponse(responseCode = "400", description = "로그인 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}), |
| 48 | + }) |
42 | 49 | @PostMapping("/login") |
43 | 50 | public ResponseEntity<JwtResponse> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) { |
44 | 51 | JwtResponse jwtResponse = userService.loginAndGetToken(loginRequest); |
|
0 commit comments