Skip to content

Conversation

@HyemIin
Copy link
Member

@HyemIin HyemIin commented Jun 16, 2025

작업 요약

  • swaggerConfig 생성
  • 의존성 추가
  • security 내 swagger 접근 경로 명시

Issue Link

#28

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신규 기능

    • OpenAPI(스웨거) 문서화 기능이 추가되어 API 명세를 확인할 수 있습니다.
    • 스웨거 UI 및 API 문서 관련 경로가 인증 없이 접근 가능해졌습니다.
    • 북마크 API 엔드포인트에 문서화 주석이 추가되어 API 사용성이 향상되었습니다.
  • 버그 수정

    • CORS 허용 오리진에 "http://localhost:8083"이 추가되어 로컬 환경에서의 접근성이 개선되었습니다.
  • 기타

    • "swagger" 프로필 사용 시 글로벌 예외 처리기가 비활성화됩니다.

- swaggerConfig 생성
- 의존성 추가
- security 내 swagger 접근 경로 명시
@HyemIin HyemIin self-assigned this Jun 16, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 16, 2025

"""

Walkthrough

이번 변경사항은 Swagger(OpenAPI) 기반의 API 문서화를 위한 설정과 주석 추가, 그리고 Swagger UI 접근을 위한 보안 및 CORS 정책의 보완이 포함되어 있습니다. 또한, Swagger 프로필 활성화 시 글로벌 예외처리기가 비활성화되도록 조정되었습니다.

Changes

파일/경로 변경 요약
build.gradle springdoc-openapi-starter-webmvc-ui 의존성 버전을 2.0.2 → 2.6.0으로 업데이트 및 주석 추가
.../BookmarkController.java 클래스 및 메서드에 Swagger(OpenAPI) 주석 추가 (@Tag, @Operation, @ApiResponse)
.../CorsConfig.java CORS 허용 origin에 http://localhost:8083 추가
.../SecurityConfig.java Swagger 관련 경로(/swagger-ui/** 등)에 인증 없이 접근 허용
.../SwaggerConfig.java OpenAPI 문서 및 JWT 인증 스키마 설정을 위한 SwaggerConfig 클래스 신규 추가
.../GlobalExceptionHandler.java @Profile("!swagger") 추가로 swagger 프로필 활성화 시 예외처리기 미적용

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SwaggerUI
    participant SpringApp
    participant SecurityConfig
    participant SwaggerConfig

    User->>SwaggerUI: Swagger UI 접속 요청 (/swagger-ui/)
    SwaggerUI->>SpringApp: API 문서 및 엔드포인트 정보 요청 (/v3/api-docs)
    SpringApp->>SwaggerConfig: OpenAPI 문서 및 JWT 인증 스키마 반환
    SpringApp->>SecurityConfig: 인증 필요 여부 확인 (Swagger 관련 경로는 permitAll)
    SpringApp-->>SwaggerUI: OpenAPI 문서 응답
    User->>SpringApp: API 호출 (JWT 토큰 포함)
    SpringApp->>SecurityConfig: JWT 인증 처리
    SpringApp-->>User: API 응답
Loading

Possibly related PRs

Poem

🦄
Swagger 바람이 불어와
북마크 API에 빛을 더하네
JWT로 보호된 문서의 길
CORS도 넓게, 예외는 조심—
개발자의 웃음꽃 피어나네!
📚✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1172b1b and 079c197.

📒 Files selected for processing (1)
  • src/main/java/com/example/gtable/global/config/SecurityConfig.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/example/gtable/global/config/SecurityConfig.java
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🧹 Nitpick comments (7)
src/main/java/com/example/gtable/global/config/CorsConfig.java (1)

18-18: 허용 Origin 리스트의 하드코딩은 설정 파일로 분리하는 편이 좋습니다

추가된 http://localhost:8083 도 개발용 도메인으로 보이는데, 운영 반영 시 Origin 을 분기하기 쉽도록 application-*.yml 또는 환경변수로 옮기면 유지보수가 수월합니다.

src/main/java/com/example/gtable/global/config/SwaggerConfig.java (1)

15-29: Swagger 설정 잘 추가되었습니다!

JWT 보안 스킴까지 포함되어 있어 기본 문서화에는 문제가 없어 보입니다.
추가로, API 버전·타이틀과 같은 메타데이터를 application.yml 프로퍼티로 분리하면 배포 파이프라인에서 쉽게 변경할 수 있습니다.

src/main/java/com/example/gtable/bookmark/controller/BookmarkController.java (5)

18-20: Swagger 어노테이션 Import 추가 확인
Swagger 문서화를 위한 주요 어노테이션을 잘 임포트하셨습니다.
만약 JWT 보안 스키마를 메서드나 클래스 레벨에 적용할 계획이라면 io.swagger.v3.oas.annotations.security.SecurityRequirement도 함께 임포트해주세요.


22-22: 클래스 레벨 @tag 활용
@Tag로 API 그룹화를 잘 적용하셨습니다.
추가로 전체 BookmarkController가 JWT 인증이 필요하다면 클래스 레벨에 @SecurityRequirement(name = "bearerAuth")를 달아 보안 스키마를 문서에 연결해보세요.


30-31: createBookmark 메서드 문서화 보강 제안
@Operation@ApiResponse(responseCode = "201")만 선언되었는데,

  • PathVariable(storeId) 파라미터 설명을 위한 @Parameter
  • 400/401/404 등 주요 에러 응답을 명시한 @ApiResponses
  • 메서드별 보안 요구사항(@SecurityRequirement)
    등을 추가하면 더욱 완성도 높은 API 스펙이 됩니다.

44-45: getAllBookmarks 메서드 응답 예시 확대 제안
성공(200) 이외에도

  • 인증 실패(401)
  • 권한 없음(403)
    등을 @ApiResponse로 문서화하시고, 반환 타입도 제네릭(ResponseEntity<ApiResponse<...>>)으로 구체화하면 API 사용자 입장에서 가독성이 높아집니다.

56-57: deleteBookmark 메서드 추가 문서화 추천
삭제 성공(200) 외에

  • 잘못된 bookmarkId(400/404)
  • 인증 문제(401/403)
    등 주요 시나리오를 @ApiResponse로 보강하고, @SecurityRequirement를 달아 보안 스킴을 연결하면 문서 완성도가 올라갑니다.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f47b85 and 1172b1b.

📒 Files selected for processing (6)
  • build.gradle (1 hunks)
  • src/main/java/com/example/gtable/bookmark/controller/BookmarkController.java (3 hunks)
  • src/main/java/com/example/gtable/global/config/CorsConfig.java (1 hunks)
  • src/main/java/com/example/gtable/global/config/SecurityConfig.java (1 hunks)
  • src/main/java/com/example/gtable/global/config/SwaggerConfig.java (1 hunks)
  • src/main/java/com/example/gtable/global/security/exception/GlobalExceptionHandler.java (2 hunks)
🔇 Additional comments (2)
build.gradle (1)

54-56: Swagger 의존성 버전 호환성 확인이 필요합니다

springdoc-openapi-starter-webmvc-ui:2.6.0 은 Spring Boot 3.5 라인과 호환되지만, 간혹 스프링 부트 마이너 릴리스에 따라 transitive 버전 충돌이 보고됩니다.
빌드 후 애플리케이션 구동-시 NoSuchMethodError 등이 발생하지 않는지 한 번 더 확인 부탁드립니다.
필요하다면 BOM(version catalog) 을 사용해 의존성 버전을 일관성 있게 관리하는 것도 고려해 주세요.

src/main/java/com/example/gtable/global/security/exception/GlobalExceptionHandler.java (1)

24-26: @Profile("!swagger") 적용 범위 재확인 권장

Swagger 프로필에서 전역 예외처리를 완전히 비활성화하면 500 에러가 그대로 노출될 수 있습니다.
API 문서용으로 특정 예외만 제외하려는 의도라면 @ConditionalOnMissingBean 또는 개별 @ExceptionHandler 메서드에 조건부 프로파일을 두는 방식을 고려해 보세요.

- security 내 swagger 접근 경로 오타 수정
@HyemIin HyemIin merged commit 2322326 into develop Jun 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants