Skip to content

Commit b5a9f64

Browse files
committed
Docs: Swagger 문서 작성
1 parent b8e8655 commit b5a9f64

File tree

2 files changed

+119
-4
lines changed

2 files changed

+119
-4
lines changed

src/main/java/com/back/domain/user/controller/AuthController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
import org.springframework.http.HttpStatus;
1414
import org.springframework.http.ResponseEntity;
1515
import org.springframework.security.access.prepost.PreAuthorize;
16-
import org.springframework.web.bind.annotation.PostMapping;
17-
import org.springframework.web.bind.annotation.RequestBody;
18-
import org.springframework.web.bind.annotation.RequestMapping;
19-
import org.springframework.web.bind.annotation.RestController;
16+
import org.springframework.web.bind.annotation.*;
2017

2118
import java.util.Map;
2219

src/main/java/com/back/domain/user/controller/AuthControllerDocs.java

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import jakarta.servlet.http.HttpServletResponse;
1616
import jakarta.validation.Valid;
1717
import org.springframework.http.ResponseEntity;
18+
import org.springframework.web.bind.annotation.GetMapping;
1819
import org.springframework.web.bind.annotation.RequestBody;
1920

2021
import java.util.Map;
@@ -237,6 +238,123 @@ ResponseEntity<RsData<LoginResponse>> login(
237238
HttpServletResponse response
238239
);
239240

241+
@Operation(
242+
summary = "소셜 로그인",
243+
description = "카카오/구글/네이버 등의 소셜 로그인을 수행합니다. " +
244+
"로그인 성공 시 Access Token을 응답 본문에, Refresh Token을 HttpOnly 쿠키에 담아 반환합니다. " +
245+
"요청 경로: /oauth2/authorization/{provider} (예: /oauth2/authorization/kakao)"
246+
)
247+
@ApiResponses({
248+
@ApiResponse(
249+
responseCode = "200",
250+
description = "소셜 로그인 성공",
251+
content = @Content(
252+
mediaType = "application/json",
253+
examples = @ExampleObject(value = """
254+
{
255+
"success": true,
256+
"code": "SUCCESS_200",
257+
"message": "소셜 로그인에 성공했습니다.",
258+
"data": {
259+
"accessToken": "{accessToken}",
260+
"user": {
261+
"userId": 1,
262+
"username": "kakao_1234567890",
263+
"email": "[email protected]",
264+
"nickname": "홍길동",
265+
"role": "USER",
266+
"status": "ACTIVE",
267+
"createdAt": "2025-09-27T15:00:00"
268+
}
269+
}
270+
}
271+
""")
272+
)
273+
),
274+
@ApiResponse(
275+
responseCode = "400",
276+
description = "지원하지 않는 Provider",
277+
content = @Content(
278+
mediaType = "application/json",
279+
examples = @ExampleObject(value = """
280+
{
281+
"success": false,
282+
"code": "AUTH_008",
283+
"message": "지원하지 않는 소셜 로그인 제공자입니다.",
284+
"data": null
285+
}
286+
""")
287+
)
288+
),
289+
@ApiResponse(
290+
responseCode = "401",
291+
description = "소셜 계정 정보 부족 / 인증 실패",
292+
content = @Content(
293+
mediaType = "application/json",
294+
examples = {
295+
@ExampleObject(name = "이메일 없음", value = """
296+
{
297+
"success": false,
298+
"code": "AUTH_010",
299+
"message": "소셜 계정에서 이메일 정보를 확인할 수 없습니다.",
300+
"data": null
301+
}
302+
"""),
303+
@ExampleObject(name = "필수 정보 누락", value = """
304+
{
305+
"success": false,
306+
"code": "AUTH_009",
307+
"message": "소셜 계정에서 필요한 사용자 정보를 가져올 수 없습니다.",
308+
"data": null
309+
}
310+
"""),
311+
@ExampleObject(name = "인증 처리 실패", value = """
312+
{
313+
"success": false,
314+
"code": "AUTH_011",
315+
"message": "소셜 로그인 인증에 실패했습니다.",
316+
"data": null
317+
}
318+
""")
319+
}
320+
)
321+
),
322+
@ApiResponse(
323+
responseCode = "404",
324+
description = "DB 사용자 조회 실패",
325+
content = @Content(
326+
mediaType = "application/json",
327+
examples = @ExampleObject(value = """
328+
{
329+
"success": false,
330+
"code": "USER_001",
331+
"message": "존재하지 않는 사용자입니다.",
332+
"data": null
333+
}
334+
""")
335+
)
336+
),
337+
@ApiResponse(
338+
responseCode = "500",
339+
description = "서버 내부 오류",
340+
content = @Content(
341+
mediaType = "application/json",
342+
examples = @ExampleObject(value = """
343+
{
344+
"success": false,
345+
"code": "COMMON_500",
346+
"message": "서버 오류가 발생했습니다.",
347+
"data": null
348+
}
349+
""")
350+
)
351+
)
352+
})
353+
@GetMapping("/docs/oauth2/authorization/{provider}")
354+
default ResponseEntity<RsData<LoginResponse>> oauth2LoginDocs() {
355+
throw new UnsupportedOperationException("Swagger 문서 전용 엔드포인트입니다.");
356+
}
357+
240358
@Operation(
241359
summary = "로그아웃",
242360
description = "사용자의 Refresh Token을 무효화하여 더 이상 토큰 재발급이 불가능하게 합니다. " +

0 commit comments

Comments
 (0)