Skip to content

Conversation

@yurim830
Copy link
Collaborator

@yurim830 yurim830 commented Aug 5, 2025

🐿️ Pull Requests

🪵 작업 브랜치

🥔 작업 내용

1. API 버저닝을 위해 ACTargetType을 구현했습니다. (Moya의 TargetType 프로토콜 상속)
우리팀 컨벤션상으로는 ACTargetTypeProtocol식으로 네이밍해야하지만,
길이가 길고, Moya의 TargetType이라는 느낌이 약해지는 것 같아 -protocol을 생략했습니다.
혹시 ACTargetTypeProtocol 으로 하는 게 좋겠다고 생각하시면 말씀해주세요!

Code

import Moya

protocol ACTargetType: TargetType {
    var apiVersion: ApiVersionType { get }
}

extension ACTargetType {

    /// API 버전 기본값 (.v1). 필요 시 각 TargetType에서 오버라이드하여 변경 가능.
    var apiVersion: ApiVersionType {
        return .v1
    }

    var utilPath: String {
        return apiVersion.utilPath
    }

}

Usage

extension UploadTargetType: ACTargetType {

    var apiVersion: ApiVersionType {
        switch self {
        case .postReview:
            return .v2
        default:
            return .v1
        }
    }

    var path: String {
        switch self {
        case .getSearchSuggestion:
            return utilPath + "spots/search-suggestions"
    ...

2. 리뷰 API 변경사항을 반영했습니다.

  • 리뷰 작성 API
  • 리뷰 작성 시 위치 인증 API
  • 추천 검색어 목록 조회 API

📸 스크린샷

image

💥 To be sure

  • 모든 뷰가 잘 실행되는지 다시 한 번 체크해주세요 !

🌰 Resolve issue

@yurim830 yurim830 linked an issue Aug 5, 2025 that may be closed by this pull request
1 task
@yurim830 yurim830 requested a review from cirtuare August 5, 2025 07:22
@yurim830 yurim830 self-assigned this Aug 5, 2025
@yurim830 yurim830 added ⚪️ network 네트워크 연결 🍀 refactor 리팩토링 🥑 유림 유림 labels Aug 5, 2025
@yurim830 yurim830 added this to the Sprint - 4 milestone Aug 5, 2025
Copy link
Contributor

@cirtuare cirtuare left a comment

Choose a reason for hiding this comment

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

리뷰 확인 부탁드립니다 ~~!

Comment on lines +1 to +42
//
// ApiVersionProtocol.swift
// ACON-iOS
//
// Created by 김유림 on 8/5/25.
//

import Foundation

import Moya

// MARK: - Protocol

protocol ACTargetType: TargetType {

var apiVersion: ApiVersionType { get }

}


// MARK: - Extension

extension ACTargetType {

var baseURL: URL {
guard let urlString = Bundle.main.object(forInfoDictionaryKey: Config.Keys.Plist.baseURL) as? String,
let url = URL(string: urlString) else {
fatalError("💢💢 BASE_URL이 없음 💢💢")
}
return url
}

/// API 버전 기본값 (.v1). 필요 시 각 TargetType에서 오버라이드하여 변경 가능.
var apiVersion: ApiVersionType {
return .v1
}

var utilPath: String {
return apiVersion.utilPath
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

🐿️🐿️🐿️
굳이 ACTargetType을 따로 만드신 이유가 있나요?? 기존 TargetType+에서 apiVersion을 선언했어도 필요한 경우만 오버라이딩하면 돼서 불필요하다고 생각합니다..!

Copy link
Collaborator Author

@yurim830 yurim830 Aug 5, 2025

Choose a reason for hiding this comment

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

b1e8428 에서 처음에 그렇게 구현했었는데,
코드를 호출해보니
protocol extension의 기본 구현은 오버라이딩이 안 되며,
가능하게 하려면 따로 프로토콜을 구현해야함을 알게 되었습니다. (참고)

오버라이딩을 포기하고 각각의 TargetType 내에서
아래처럼 손수 utilPath를 구현하자니 확장성이 너무 떨어져서,
위 코드처럼 ACTargetType 프로토콜을 만들게 되었습니다

    var apiVersion: ApiVersion {
        switch self {
        case .getSearchSuggestion,
            return .v2
        default:
            return .v2
        }
    }

    var utilPath: String {
        return apiVersion.path
    }

   var path: String {
        switch self {
        case .getSearchSuggestion:
            return utilPath + "search-suggestions"
 ....

Copy link
Contributor

Choose a reason for hiding this comment

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

확인했습니다 !!!!

@cirtuare cirtuare self-requested a review August 5, 2025 10:32
@yurim830 yurim830 merged commit 220a142 into develop Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚪️ network 네트워크 연결 🍀 refactor 리팩토링 🥑 유림 유림

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] API 버저닝을 위한 ACTargetType 구현, 리뷰 API 수정

3 participants