HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
♥️
2기 최종 프로젝트 팀별 공간
/
팀 02 : 머쓱한녀석들
팀 02 : 머쓱한녀석들
/
🎏
BackEnd
/
👒
Swaager 전략
👒

Swaager 전략

Controller

@Tag(name = "유저", description = "유저 관련 API입니다.") @RestController public class TestController { @Operation(summary = "유저 다건 조회", description = "유저 단건 조회 API입니다.") @GetMapping("/users") public ResponseEntity<TestResponse> get() { return ResponseEntity.ok(new TestResponse("test")); } @Operation(summary = "유저 가입", description = "유저 가입 API입니다.") @PostMapping("/users") public ResponseEntity<TestResponse> post( @RequestBody TestRequest testRequest ) { TestResponse response = new TestResponse("1"); URI location = ServletUriComponentsBuilder.fromCurrentRequest() .path("{id}") .buildAndExpand(response.getName()) .toUri(); return ResponseEntity.created(location) .body(response); } }
  • @Tag : api 그룹 설정을 위한 어노테이션
    • name, description 작성
  • @Operation : api 상세 정보 설정을 위한 어노테이션
    • summary, description 작성
 

DTO

public class TestRequest { @Schema(description = "이름", defaultValue = "testName") private String name; } public class TestResponse { @Schema(description = "반환 이름", defaultValue = "testName") private String name; }
  • @Schema : Request, Resposne 객체에 대한 설정을 위한 어노테이션
    • description 작성
 

참고

👓
Swaager에 대해