Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#20): Swagger 문서 작성 #29

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/main/java/kusitms/hdmedi/controller/user/UserController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package kusitms.hdmedi.controller.user;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import kusitms.hdmedi.dto.request.user.LoginRequest;
import kusitms.hdmedi.dto.response.news.NewsListResponse;
import kusitms.hdmedi.dto.response.news.NewsResponse;
import kusitms.hdmedi.dto.response.user.InfoResponse;
import kusitms.hdmedi.dto.response.user.LoginResponse;
import kusitms.hdmedi.exception.base.BaseResponse;
Expand All @@ -12,13 +21,19 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "user", description = "유저 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/auth")
public class UserController {
private final UserService userService;

// 로그인
@Operation(description = "로그인하기", summary = "로그인")
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(schema = @Schema(implementation = LoginResponse.class)))
@Parameter(name = "loginId", description = "로그인 ID")
@Parameter(name = "password", description = "패스워드")
@PostMapping("/login")
public BaseResponse<LoginResponse> webLogin(@RequestBody @Validated LoginRequest req, BindingResult bindingResult) throws Exception {
if (bindingResult.hasErrors()) {
Expand All @@ -31,8 +46,13 @@ public BaseResponse<LoginResponse> webLogin(@RequestBody @Validated LoginRequest
}

// 유저 정보
@Operation(description = "유저 정보 조회하기", summary = "유저 정보 조회")
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(schema = @Schema(implementation = InfoResponse.class)))
@Parameter(name = "Bearer 토큰", required = true)
@GetMapping("/info")
public BaseResponse<InfoResponse> userInfo(Authentication auth) {
public BaseResponse<InfoResponse> userInfo(
@RequestHeader(value="Authorization") Authentication auth) {

InfoResponse result = userService.getUserInfo(auth.getName());
return BaseResponse.onSuccess(result);
Expand Down