Skip to content

Commit

Permalink
swagger 오류 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
woojin065 committed Jun 16, 2024
1 parent e3ac070 commit 9de1f2d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.example.moreveiw.domain.S3.model.dto.S3UrlResponse;
import com.example.moreveiw.domain.S3.service.S3Service;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
Expand All @@ -12,16 +14,19 @@
@RestController
@RequiredArgsConstructor
@CrossOrigin("*")
@Tag(name = "S3 Controller", description = "S3 관련 API")
public class S3Controller {
private final S3Service imageService;

@PostMapping(value = "/file",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "이미지 업로드", description = "S3에 이미지를 업로드합니다.")
public S3UrlResponse uploadImage(@RequestBody MultipartFile file) throws IOException {
return imageService.uploadImage(file);
}

@DeleteMapping("/file")
@Operation(summary = "이미지 삭제", description = "S3에서 이미지를 삭제합니다.")
public boolean deleteImage(@RequestParam String fileUrl) {
return imageService.deleteImage(fileUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.example.moreveiw.domain.member.service.MemberService;
import com.example.moreveiw.global.security.jwt.JwtFilter;
import com.example.moreveiw.global.security.jwt.TokenProvider;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,18 +25,21 @@
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Tag(name = "Member Controller", description = "회원 관련 API")
public class MemberController {

private final TokenProvider tokenProvider;
private final AuthenticationManagerBuilder authenticationManagerBuilder;
private final MemberService memberService;

@PostMapping("/sign-in")
@Operation(summary = "회원가입", description = "새로운 회원을 가입시킵니다.")
public ResponseEntity<MemberResponse> signIn(@Valid @RequestBody MemberRequest request) {
return ResponseEntity.ok(memberService.signup(request));
}

@PostMapping("/login")
@Operation(summary = "로그인", description = "회원 로그인을 처리합니다.")
public ResponseEntity<TokenDto> authorize(@Valid @RequestBody MemberLoginRequest request) {

UsernamePasswordAuthenticationToken authenticationToken =
Expand All @@ -53,6 +58,7 @@ public ResponseEntity<TokenDto> authorize(@Valid @RequestBody MemberLoginRequest

@GetMapping("/user")
@PreAuthorize("hasAnyRole('USER','ADMIN')")
@Operation(summary = "유저 정보 조회", description = "로그인한 유저의 정보를 조회합니다.")
public ResponseEntity<MemberResponse> getMyUserInfo(HttpServletRequest request) {
return ResponseEntity.ok(memberService.getMyMemberWithAuthorities());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequiredArgsConstructor
@Validated
@CrossOrigin("*")
@Tag(name = "3D AI Controller", description = "3D AI 관련 API")
public class ThreeDAIController {
private final ThreeDAIService threeDAIService;

@PostMapping("/treeDAI")
@Operation(summary = "3D AI 생성", description = "이름을 받아 3D AI를 생성합니다.")
public String makeThreeDAI(@RequestBody String name) throws IOException {
return threeDAIService.makeThreeDAI(name);
}

@GetMapping("/treeDAI")
@Operation(summary = "3D AI 조회", description = "이름을 받아 3D AI 정보를 조회합니다.")
public ThreeDAIResponse getThreeDAI(@RequestParam String name) {
return threeDAIService.getThreeDAI(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequiredArgsConstructor
@RequestMapping("chat-rooms")
@Tag(name = "WebSocket Controller", description = "WebSocket 관련 API")
public class ChatController {

private final ProjectService chatService;

// RoomName으로 채팅방 생성
@PostMapping
@Operation(summary = "채팅방 생성", description = "새로운 채팅방을 생성합니다.")
public ProjectRoom createRoom() {
return chatService.createProjectRoom();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Controller
@RequiredArgsConstructor
@Tag(name = "Stomp Controller", description = "STOMP WebSocket API")
public class StompController {

@MessageMapping("/hello")
@SendTo("/sub/greetings")
@Operation(summary = "메시지 보내기", description = "메시지를 받아서 구독자에게 보냅니다.")
public String greeting(String message) throws Exception {
return message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

@Configuration
public class AWSConfig {
@Value("${AWS_ACCESS_KEY}")
@Value("application.yml.cloud.aws.credentials.accessKey")
private String AWS_ACCESS_KEY;
@Value("${AWS_SECRET_KEY}")
@Value("application.yml.cloud.aws.credentials.secretKey")
private String AWS_SECRET_KEY;

private final String region = "ap-northeast-2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

.authorizeHttpRequests(authorizeHttpRequest -> authorizeHttpRequest
.requestMatchers("/api/sign-in", "api/login").permitAll()
.requestMatchers(PathRequest.toH2Console()).permitAll()
.requestMatchers("/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**").permitAll() // 스웨거 경로 허용
.requestMatchers(("/file/**")).permitAll()
.anyRequest().authenticated()
)

Expand Down

0 comments on commit 9de1f2d

Please sign in to comment.