From d9321fbf0f0399acbe329f841221edcd459519ba Mon Sep 17 00:00:00 2001 From: Tomas Cejka Date: Wed, 31 Jul 2024 12:14:13 +0200 Subject: [PATCH] [fix] allow to override default json decoder on APIManager --- Sources/Networking/Core/APIManager.swift | 8 ++++++++ Sources/Networking/Core/APIManaging.swift | 13 ------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Sources/Networking/Core/APIManager.swift b/Sources/Networking/Core/APIManager.swift index da1ce51e..3f718ec6 100644 --- a/Sources/Networking/Core/APIManager.swift +++ b/Sources/Networking/Core/APIManager.swift @@ -39,11 +39,19 @@ import Foundation ``` */ open class APIManager: APIManaging, Retryable { + // MARK: Public variables + /// Default JSONDecoder implementation + public var defaultDecoder: JSONDecoder { + JSONDecoder() + } + + // MARK: Private variables private let requestAdapters: [RequestAdapting] private let responseProcessors: [ResponseProcessing] private let errorProcessors: [ErrorProcessing] private let responseProvider: ResponseProviding private let sessionId: String + internal var retryCounter = Counter() public init( diff --git a/Sources/Networking/Core/APIManaging.swift b/Sources/Networking/Core/APIManaging.swift index 1f9e587c..96971a6f 100644 --- a/Sources/Networking/Core/APIManaging.swift +++ b/Sources/Networking/Core/APIManaging.swift @@ -39,11 +39,6 @@ public protocol APIManaging { // MARK: - Provide request with default json decoder, retry configuration public extension APIManaging { - /// Default JSONDecoder implementation. - var defaultDecoder: JSONDecoder { - JSONDecoder.default - } - /// Simplifies request using a default ``RetryConfiguration``. /// - Parameter endpoint: API endpoint requestable definition. /// - Returns: ``Response``. @@ -88,11 +83,3 @@ public extension APIManaging { return try decoder.decode(DecodableResponse.self, from: response.data) } } - - -// MARK: - JSONDecoder static extension - -private extension JSONDecoder { - /// A static `JSONDecoder` instance used by default implementation of `APIManaging` - static let `default` = JSONDecoder() -}