Skip to content

Commit 4599172

Browse files
authored
Merge pull request #71 from strvcom/fix/default-json-decoder
[fix] allow to override default json decoder on APIManager
2 parents 03995a3 + d9321fb commit 4599172

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Diff for: Sources/Networking/Core/APIManager.swift

+8
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,19 @@ import Foundation
3939
```
4040
*/
4141
open class APIManager: APIManaging, Retryable {
42+
// MARK: Public variables
43+
/// Default JSONDecoder implementation
44+
public var defaultDecoder: JSONDecoder {
45+
JSONDecoder()
46+
}
47+
48+
// MARK: Private variables
4249
private let requestAdapters: [RequestAdapting]
4350
private let responseProcessors: [ResponseProcessing]
4451
private let errorProcessors: [ErrorProcessing]
4552
private let responseProvider: ResponseProviding
4653
private let sessionId: String
54+
4755
internal var retryCounter = Counter()
4856

4957
public init(

Diff for: Sources/Networking/Core/APIManaging.swift

-13
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public protocol APIManaging {
3939
// MARK: - Provide request with default json decoder, retry configuration
4040

4141
public extension APIManaging {
42-
/// Default JSONDecoder implementation.
43-
var defaultDecoder: JSONDecoder {
44-
JSONDecoder.default
45-
}
46-
4742
/// Simplifies request using a default ``RetryConfiguration``.
4843
/// - Parameter endpoint: API endpoint requestable definition.
4944
/// - Returns: ``Response``.
@@ -88,11 +83,3 @@ public extension APIManaging {
8883
return try decoder.decode(DecodableResponse.self, from: response.data)
8984
}
9085
}
91-
92-
93-
// MARK: - JSONDecoder static extension
94-
95-
private extension JSONDecoder {
96-
/// A static `JSONDecoder` instance used by default implementation of `APIManaging`
97-
static let `default` = JSONDecoder()
98-
}

0 commit comments

Comments
 (0)