Skip to content

Commit

Permalink
Merge pull request #14 from YAPP-Github/feat/ISSUE-11
Browse files Browse the repository at this point in the history
feat: connect swagger to auth APIs
  • Loading branch information
Seokyeong237 authored Jan 14, 2024
2 parents d15f501 + e9e3687 commit edd3613
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public AuthResponseDto socialLogin(SocialInfoResponseDto socialResponseDto) {
String accessToken = jwtTokenProvider.generateAccessToken(authentication);

return AuthResponseDto.builder()
.flag(member.isFlag())
.onBoardingFlag(member.isFlag())
.accessToken(accessToken)
.refreshToken(socialResponseDto.getRefreshToken())
.build();
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/fullcar/member/presentation/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import com.fullcar.member.presentation.dto.response.AuthResponseDto;
import com.fullcar.member.presentation.dto.response.AuthTokenResponseDto;
import com.fullcar.member.presentation.dto.response.SocialInfoResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
Expand All @@ -17,9 +21,17 @@
@RestController
@RequestMapping("/api/v1/auth")
@RequiredArgsConstructor
@Tag(name = "[Auth] 인증/인가 관련 API")
public class AuthController {
private final AuthServiceProvider authServiceProvider;

@Operation(summary = "소셜 로그인 API")
@ApiResponses(value = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "소셜로그인 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "애플 공개키 생성 중 문제 발생", content = @Content),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "유효하지 않은 카카오 토큰", content = @Content),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content)
})
@PostMapping()
public ApiResponse<AuthResponseDto> socialLogin(@RequestBody AuthRequestDto authRequestDto) {

Expand All @@ -30,6 +42,12 @@ public ApiResponse<AuthResponseDto> socialLogin(@RequestBody AuthRequestDto auth
return ApiResponse.success(SuccessCode.SIGNIN_SUCCESS, responseDto);
}

@Operation(summary = "토큰 재발급 API")
@ApiResponses(value = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "토큰 재발급 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "1. access, refreshToken 모두 만료되었습니다. 재로그인이 필요합니다. \t\n 2. 유효하지 않은 토큰", content = @Content),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content)
})
@GetMapping("/token")
@ResponseStatus(HttpStatus.OK)
public ApiResponse<AuthTokenResponseDto> getNewToken(@RequestBody AuthTokenRequestDto authTokenRequestDto) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fullcar.member.presentation.dto.request;

import com.fullcar.member.domain.MemberSocialType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -11,7 +12,12 @@
@NoArgsConstructor(access = PROTECTED)
public class AuthRequestDto {

@Schema(description = "소셜로그인 타입")
private MemberSocialType socialType;

@Schema(description = "소셜로그인 토큰", example = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3MDUyMzQ2NjMsImV4cCI6MTcwNTIzNDg0MywibWVtYmVySWQiOiJjb20uZnVsbGNhci5tZW1iZXIuZG9tYWluLk1lbWJlcklkQDQ5ODRlODM3In0.Qf8uXvaWR9K_pD4jgZlnkFpcx2-zlRKENXJhGXkMGSs")
private String token;

@Schema(description = "디바이스 토큰")
private String deviceToken;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.fullcar.member.presentation.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

@Getter
public class AuthTokenRequestDto {

@Schema(description = "리프레쉬 토큰")
private String refreshToken;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package com.fullcar.member.presentation.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class AuthResponseDto {

private Boolean flag;
@Schema(description = "멤버 온보딩 여부")
private Boolean onBoardingFlag;

@Schema(description = "FullCar Access Token")
private String accessToken;

@Schema(description = "FullCar Refresh Token")
private String refreshToken;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.fullcar.member.presentation.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class AuthTokenResponseDto {

@Schema(description = "FullCar Access Token", example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
private String accessToken;

@Schema(description = "FullCar Refresh Token", example = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
private String refreshToken;
}

0 comments on commit edd3613

Please sign in to comment.