Skip to content

[REFACTOR] 사용자, 무드, 장소 관련 도메인 Annotation 재정비#250

Merged
kaswhy merged 14 commits intodevelopfrom
refactor/#249/refactoring-annotations
Feb 23, 2026
Merged

[REFACTOR] 사용자, 무드, 장소 관련 도메인 Annotation 재정비#250
kaswhy merged 14 commits intodevelopfrom
refactor/#249/refactoring-annotations

Conversation

@kaswhy
Copy link
Member

@kaswhy kaswhy commented Feb 22, 2026

👀 Summary

🖇️ Tasks

  • auth 도메인 annotation 재정비
  • curation 도메인 annotation 재정비
  • home 도메인 annotation 재정비
  • mood 도메인 annotation 재정비
  • photo 도메인 annotation 재정비
  • photographer 도메인 annotation 재정비
  • place 도메인 annotation 재정비
  • user 도메인 annotation 재정비

🔍 To Reviewer

❶ 가독성에 관한 고민

컨벤션을 다시 정하면서 API 인터페이스 쪽에 많은 어노테이션이 붙습니다. 하나의 파라미터에 대해 여러 어노테이션이 붙는 경우가 많고, 여러 파라미터가 있어 인터페이스 측에서는 한 줄 당 하나의 어노테이션만 붙였습니다. 또한, 파라미터 간 개행으로 파라미터를 조금 더 명확하게 작성하기 위해 노력했습니다.

반면, 컨트롤러 구현체에서는 인증 어노테이션을 제외하면 거의 모든 어노테이션이 붙지 않기 때문에 파라미터 간에 개행을 하지 않았고, 각 파라미터에 들어가는 어노테이션은 파라미터와 함께 한 줄에 작성했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

📝 Walkthrough

Walkthrough

스프링 웹 매핑(@GetMapping, @PostMapping 등)과 일부 검증/메타데이터(@Valid, @Parameter 등) 애노테이션이 여러 v1 도메인에서 Controller와 Api 인터페이스 간에 이동되었습니다. 일부 파라미터는 @Parameter(hidden = true)로 표시되었고 인증 관련 파라미터 바인딩 방식이 조정되었습니다. (50단어 미만)

Changes

Cohort / File(s) Summary
Auth 도메인
src/main/java/org/sopt/snappinserver/api/v1/auth/controller/AuthApi.java, src/main/java/org/sopt/snappinserver/api/v1/auth/controller/AuthController.java
/login/kakao, /reissue, /logout에 대한 @PostMapping@Parameter 기반 파라미터 설명이 AuthApi로 추가됨. 컨트롤러에서는 매핑·바인딩 애노테이션이 제거되어 인터페이스 기반 노출로 이동. AuthenticationPrincipal 대신 CustomUserInfo가 hidden 파라미터로 표기됨.
Curation 도메인
src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java, .../CurationController.java
getCurationQuestion, createMoodCuration, getAllCurationQuestions의 매핑이 Api로 이동하고 파라미터 애노테이션 포맷(줄바꿈)이 정리됨; Controller에서 매핑 제거.
Home 도메인
src/main/java/org/sopt/snappinserver/api/v1/home/controller/HomeApi.java, .../HomeController.java
getRecommendation()@GetMapping("/recommendation")이 Api에 추가되고 Controller에서는 매핑 제거(노출 위치 변경).
Mood 도메인
src/main/java/org/sopt/snappinserver/api/v1/mood/controller/MoodApi.java, .../MoodController.java
getAllMoodFilters@GetMapping이 Api로 추가되고 Controller에서 해당 매핑이 제거됨.
Photo 도메인
src/main/java/org/sopt/snappinserver/api/v1/photo/controller/PhotoApi.java, .../PhotoController.java
createPhotoMoodConnection@PostMapping("/process")@Valid 등 검증·매핑 애노테이션이 Api로 이동; Controller에서는 매핑과 파라미터 애노테이션 제거.
Photographer 도메인
src/main/java/org/sopt/snappinserver/api/v1/photographer/controller/PhotographerApi.java, .../PhotographerController.java
getPhotographerProfile@GetMapping("/{photographerId}")@Parameter로 설명 추가(검증 주석 유지/조정). Controller에서 메서드 매핑 제거.
Place 도메인
src/main/java/org/sopt/snappinserver/api/v1/place/controller/PlaceApi.java, .../PlaceController.java
getPlaces@GetMapping@Parameter(keyword 설명) 추가. Controller에서 메서드 매핑 제거.
User 도메인
src/main/java/org/sopt/snappinserver/api/v1/user/controller/UserApi.java, .../UserController.java
getUserInfo@GetMapping("/me"), patchUserRole@PatchMapping("/role")이 Api로 추가. Controller에서는 매핑과 @RequestHeader 제거; @Parameter(hidden = true) 등 메타데이터는 Api에 존재.
v2 Auth Api (형식 변경)
src/main/java/org/sopt/snappinserver/api/v2/auth/controller/AuthApi.java
애노테이션 위치·포맷(줄바꿈) 조정만 있음 — 기능적 변경 없음.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • earl9rey

Poem

애노테이션들이 줄을 바꿔 춤추네 💃
Api는 길을 잡고 Controller는 숨을 고르네
매핑 하나 옮겨 자리 바뀌어도
요청은 조용히 목적지를 향하리니
고생하셨어요 — 코드에 박수 👏

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 나타냅니다. 여러 도메인에 걸친 Annotation 재정비라는 주요 목표를 간결하게 표현했습니다.
Description check ✅ Passed PR 설명이 변경사항과 관련이 있으며, 수행된 작업 목록과 검토자를 위한 상세한 가이드를 제공합니다.
Linked Issues check ✅ Passed PR의 모든 변경사항이 #249 이슈의 요구사항을 충족합니다. 8개 도메인의 Annotation 재정비가 완료되었으며, API 인터페이스와 컨트롤러의 컨벤션 정의가 일관되게 적용되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 Annotation 재정비라는 명확한 범위 내에 있습니다. 비즈니스 로직 변경이나 불필요한 파일 수정은 없으며, 스코프에 정확히 부합합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#249/refactoring-annotations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationController.java (1)

25-27: ⚠️ Potential issue | 🔴 Critical

@Validated 누락 — 파라미터 검증이 런타임에 동작하지 않습니다

@NotNull, @Min, @Max와 같은 메서드 파라미터 레벨 Bean Validation은 Spring의 AOP 프록시를 통해 동작합니다. 이 프록시를 활성화하려면 컨트롤러 클래스에 @Validated가 선언되어야 하는데, 현재 누락되어 있습니다. 결과적으로 step 파라미터에 부착된 제약 조건들은 런타임에 전혀 적용되지 않습니다.

코딩 가이드라인에도 @Validated는 컨트롤러 구현체에 위치해야 한다고 명시되어 있습니다.

🛠️ 제안 수정
 `@RequestMapping`("/api/v1/curation")
 `@RequiredArgsConstructor`
+@Validated
 `@RestController`
 public class CurationController implements CurationApi {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationController.java`
around lines 25 - 27, The CurationController class is missing the `@Validated`
annotation so method-level Bean Validation on parameters like the step parameter
(e.g., constraints such as `@NotNull/`@Min/@Max) will not be enforced at runtime;
add the Spring `@Validated` annotation to the CurationController class declaration
(alongside `@RestController/`@RequestMapping/@RequiredArgsConstructor) to enable
AOP-based parameter validation and ensure existing parameter constraint
annotations on methods in CurationController are activated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java`:
- Around line 34-35: The step parameter in the CurationApi interface must carry
the validation annotations (`@NotNull`, `@Min`, `@Max`) instead of relying on the
implementation; update the step `@RequestParam` declaration in CurationApi (method
parameter named step) to include the appropriate annotations and remove any
duplicated validation annotations from CurationController so only the interface
defines the validation contract.

In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationController.java`:
- Around line 38-41: Remove the validation annotations (`@NotNull`, `@Min`, `@Max`)
from the controller implementation (CurationController) and place them on the
corresponding method signature/parameter in the API contract interface
(CurationApi) so the validation metadata lives on the interface for the
parameter "Integer step"; ensure the controller method parameters no longer
carry those annotations and the CurationApi method has the same parameter
name/type annotated with `@NotNull`(message="단계는 필수입니다."), `@Min`(value=1,
message="단계는 1 이상이어야 합니다."), and `@Max`(value=5, message="단계는 5 이하여야 합니다.") to
comply with the coding guideline.

In
`@src/main/java/org/sopt/snappinserver/api/v1/photographer/controller/PhotographerApi.java`:
- Around line 21-25: Add the missing parameter validation annotations to the
interface method getPhotographerProfile in PhotographerApi: restore `@NotNull` and
`@Positive` on the photographerId `@PathVariable` so the validation lives on the
interface (not in PhotographerController). Update the method signature for
ApiResponseBody<GetPhotographerProfileResponse, Void>
getPhotographerProfile(...) to include `@NotNull` and `@Positive` on the Long
photographerId parameter and keep the existing `@PathVariable` and `@Schema`
annotations.

In
`@src/main/java/org/sopt/snappinserver/api/v1/photographer/controller/PhotographerController.java`:
- Around line 3-4: Move the parameter validation annotations (`@NotNull`,
`@Positive`, etc.) out of the PhotographerController implementation methods and
place them on the corresponding method parameters in the PhotographerApi
interface (add the same annotations to the interface method signatures), then
remove those annotations and their imports from PhotographerController so
validation is declared on the interface (PhotographerApi) not the
implementation; ensure you do not duplicate mapping/validation annotations on
both interface and controller methods.

In
`@src/main/java/org/sopt/snappinserver/api/v1/place/controller/PlaceController.java`:
- Around line 22-26: Move the parameter validation annotations from
PlaceController.getPlaces to the PlaceApi.getPlaces declaration: add `@NotBlank`
and `@Length` (and the `@RequestParam/`@Schema metadata) on the interface method
parameter so validation metadata lives on the API contract; then remove those
validation annotations from PlaceController.getPlaces and annotate the
PlaceController class with `@Validated` so Spring's method-level validation
(MethodValidationInterceptor) runs at runtime. Ensure you reference the same
parameter name and keep the method signature getPlaces in both PlaceApi and
PlaceController consistent.

---

Outside diff comments:
In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationController.java`:
- Around line 25-27: The CurationController class is missing the `@Validated`
annotation so method-level Bean Validation on parameters like the step parameter
(e.g., constraints such as `@NotNull/`@Min/@Max) will not be enforced at runtime;
add the Spring `@Validated` annotation to the CurationController class declaration
(alongside `@RestController/`@RequestMapping/@RequiredArgsConstructor) to enable
AOP-based parameter validation and ensure existing parameter constraint
annotations on methods in CurationController are activated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/org/sopt/snappinserver/api/v1/place/controller/PlaceApi.java`:
- Line 22: 현재 파라미터에 붙어있는 `@Schema`(description = "장소 검색어")를 제거하고 Springdoc 권장 및
프로젝트 가이드라인에 맞게 `@Parameter로` 대체하세요; 구체적으로 PlaceApi 인터페이스의 해당 요청 파라미터에 적용된 `@Schema를`
`@Parameter`(...)로 바꾸고 (프로젝트 규약에 따라 인터페이스 레이어라면 `@Parameter`(hidden = true) 형태를
사용하거나 필요한 경우 description 속성을 제공) 관련 어노테이션 충돌(예: `@NotBlank`, `@Length` 등)이 발생하지 않도록
검토해서 문서가 덮어써지지 않게 수정하세요.
- Line 20: In PlaceApi update the method parameter annotation for the search
term: replace the use of `@Schema`(...) on the parameter named keyword with
`@Parameter`(description = "장소 검색어") while keeping `@NotBlank`(...) and
`@RequestParam`, and add the import for io.swagger.v3.oas.annotations.Parameter
(and remove unused `@Schema` import if applicable) so the Swagger UI shows
validation metadata and the description correctly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java (1)

23-23: ⚠️ Potential issue | 🟡 Minor

@Validated는 인터페이스가 아닌 컨트롤러 구현체에 위치해야 합니다.

코딩 가이드라인에 따르면 @Validated는 "AOP 기반 검증 활성화" 목적으로 컨트롤러 구현체에 선언해야 합니다. 현재 CurationApi 인터페이스에만 있고 CurationController 구현체에는 없으므로, 다음과 같이 정리해 주시기 바랍니다.

✏️ 수정 제안

CurationApi.java (인터페이스에서 제거):

 `@Tag`(name = "03 - Curation", description = "무드 큐레이션 관련 API")
-@Validated
 public interface CurationApi {

CurationController.java (구현체에 추가):

+@Validated
 `@RequestMapping`("/api/v1/curation")
 `@RequiredArgsConstructor`
 `@RestController`
 public class CurationController implements CurationApi {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java`
at line 23, Remove the `@Validated` annotation from the CurationApi interface and
add it to the controller implementation class CurationController (the class that
implements CurationApi) so AOP-based validation is activated on the concrete
controller; update imports if necessary and ensure only CurationController is
annotated with `@Validated` while CurationApi no longer carries that annotation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java`:
- Line 35: The Swagger `@Parameter` annotation for the step parameter in
CurationApi currently lacks required=true even though `@NotNull` enforces it;
update the `@Parameter` on the method parameter (the one annotated with
`@Parameter`(description = "조회할 단계", example = "1") and `@NotNull`) to include
required = true so the OpenAPI/Swagger docs correctly reflect that the parameter
is mandatory.

In `@src/main/java/org/sopt/snappinserver/api/v1/place/controller/PlaceApi.java`:
- Line 22: The `@Parameter` annotation on the method parameter 'keyword' in
PlaceApi.java doesn't declare required=true so Swagger may show it as optional
even though `@NotBlank` enforces it; update the `@Parameter` on the 'keyword'
RequestParam in the PlaceApi controller to include required = true (and
optionally an example/description) so the OpenAPI docs match the `@NotBlank`
validation.

---

Outside diff comments:
In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java`:
- Line 23: Remove the `@Validated` annotation from the CurationApi interface and
add it to the controller implementation class CurationController (the class that
implements CurationApi) so AOP-based validation is activated on the concrete
controller; update imports if necessary and ensure only CurationController is
annotated with `@Validated` while CurationApi no longer carries that annotation.

CustomUserInfo userInfo,

@Schema(description = "조회할 단계", example = "1")
@Parameter(description = "조회할 단계", example = "1")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

@Parameterrequired = true 추가를 고려해 주세요.

@NotNull로 필수 파라미터임을 검증하고 있지만, Swagger 문서에서는 @Parameterrequired 속성이 기본값 false로 표시됩니다. API 명세의 정확성을 위해 추가해 주시면 좋을 것 같습니다.

✏️ 수정 제안
-        `@Parameter`(description = "조회할 단계", example = "1")
+        `@Parameter`(description = "조회할 단계", example = "1", required = true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Parameter(description = "조회할 단계", example = "1")
`@Parameter`(description = "조회할 단계", example = "1", required = true)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/sopt/snappinserver/api/v1/curation/controller/CurationApi.java`
at line 35, The Swagger `@Parameter` annotation for the step parameter in
CurationApi currently lacks required=true even though `@NotNull` enforces it;
update the `@Parameter` on the method parameter (the one annotated with
`@Parameter`(description = "조회할 단계", example = "1") and `@NotNull`) to include
required = true so the OpenAPI/Swagger docs correctly reflect that the parameter
is mandatory.

)
@GetMapping
ApiResponseBody<GetPlaceListResponse, Void> getPlaces(
@Parameter(description = "장소 검색어")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

@Parameterrequired = true 속성 추가를 고려해 주세요.

keyword 파라미터는 @NotBlank로 필수임을 나타내고 있지만, @Parameterrequired 속성이 명시되지 않아 Swagger UI에서 해당 파라미터가 선택 사항으로 보일 수 있습니다. 문서와 실제 검증 동작이 일치하도록 아래와 같이 보완하면 좋을 것 같습니다.

✨ 제안 수정
-        `@Parameter`(description = "장소 검색어")
+        `@Parameter`(description = "장소 검색어", required = true)

Based on learnings: "메서드 파라미터(RequestParam, PathVariable, RequestHeader 등)에는 @Parameter 어노테이션을 사용하고, description, required, example 속성을 적절히 활용해야 합니다."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/sopt/snappinserver/api/v1/place/controller/PlaceApi.java`
at line 22, The `@Parameter` annotation on the method parameter 'keyword' in
PlaceApi.java doesn't declare required=true so Swagger may show it as optional
even though `@NotBlank` enforces it; update the `@Parameter` on the 'keyword'
RequestParam in the PlaceApi controller to include required = true (and
optionally an example/description) so the OpenAPI docs match the `@NotBlank`
validation.

Copy link
Contributor

@earl9rey earl9rey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다!! 수고 많으셨어요 ~~

소연 ♡ 개행

@kaswhy kaswhy merged commit 405a44d into develop Feb 23, 2026
2 checks passed
@kaswhy kaswhy deleted the refactor/#249/refactoring-annotations branch February 23, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚒️ [REFACTOR] 사용자, 무드, 장소 관련 도메인 Annotation 재정비

2 participants