Skip to content

Commit

Permalink
유저 컨트롤러 스웨거 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gidskql6671 committed May 28, 2024
1 parent bd07e87 commit 3f0c56b
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package knu.dong.onedayonebaek.user.controller

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.ExampleObject
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import knu.dong.onedayonebaek.common.exception.response.UnauthorizedResponse
import knu.dong.onedayonebaek.user.domain.User
import knu.dong.onedayonebaek.user.dto.toUserDto
import org.springframework.security.core.Authentication
Expand All @@ -13,6 +20,22 @@ import org.springframework.web.bind.annotation.RestController
@Tag(name = "User APIs", description = "유저 정보와 관련된 APIs")
class UserController {

@Operation(
summary = "로그인된 유저의 정보 조회",
description = "로그인된 유저의 정보를 조회한다."
)
@ApiResponses(
ApiResponse(responseCode = "200", description = "로그인된 유저 정보"),
ApiResponse(
responseCode = "401", description = "로그인 되지 않음",
content = [Content(
examples = [ExampleObject(
name = "로그인 되지 않음",
value = "{\"code\": \"access_token_expired\", \"message\":\"Access token expired\"}"
)],
schema = Schema(implementation = UnauthorizedResponse::class))],
)
)
@GetMapping
fun loginUserInfo(authentication: Authentication) = (authentication.principal as User).toUserDto()
}

0 comments on commit 3f0c56b

Please sign in to comment.