Skip to content

Commit 68d22bb

Browse files
committed
task: Deprecation messages
1 parent 06af48f commit 68d22bb

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

Sources/GoodNetworking/Models/Endpoint.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ public enum EndpointParameters {
143143

144144
// MARK: - Compatibility
145145

146-
@available(*, deprecated)
146+
@available(*, deprecated, message: "Encoding will be automatically determined by the kind of `parameters` in the future.")
147147
public protocol ParameterEncoding {}
148148

149-
@available(*, deprecated)
149+
@available(*, deprecated, message: "Encoding will be automatically determined by the kind of `parameters` in the future.")
150150
public enum URLEncoding: ParameterEncoding {
151151
case `default`
152152
}
153153

154-
@available(*, deprecated)
154+
@available(*, deprecated, message: "Encoding will be automatically determined by the kind of `parameters` in the future.")
155155
public enum JSONEncoding: ParameterEncoding {
156156
case `default`
157157
}
158158

159-
@available(*, deprecated)
159+
@available(*, deprecated, message: "Encoding will be automatically determined by the kind of `parameters` in the future.")
160160
public enum AutomaticEncoding: ParameterEncoding {
161161
case `default`
162162
}

Sources/GoodNetworking/Models/JSON.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ import Foundation
7171

7272
// MARK: - Initializers
7373

74-
/// Create JSON from raw `Data`
74+
/// Create JSON from raw `Data`.
75+
///
7576
/// - Parameters:
7677
/// - data: Raw `Data` of JSON object
7778
/// - options: Optional serialization options
@@ -90,8 +91,9 @@ import Foundation
9091
/// - model: `Encodable` model
9192
/// - encoder: Encoder for encoding the model
9293
public init(encodable model: any Encodable, encoder: JSONEncoder) {
93-
if let data = try? encoder.encode(model), let converted = try? JSON(data: data) {
94-
self = converted
94+
if let data = try? encoder.encode(model),
95+
let jsonData = try? JSON(data: data) {
96+
self = jsonData
9597
} else {
9698
self = JSON.null
9799
}
@@ -105,20 +107,20 @@ import Foundation
105107
///
106108
/// - Parameter object: Object to try to represent as JSON
107109
public init(_ object: Any) {
108-
if let data = object as? Data, let converted = try? JSON(data: data) {
109-
self = converted
110-
} else if let model = object as? any Encodable, let data = try? JSONEncoder().encode(model), let converted = try? JSON(data: data) {
111-
self = converted
110+
if let data = object as? Data, let jsonData = try? JSON(data: data) {
111+
self = jsonData
112+
} else if let model = object as? any Encodable, let data = try? JSONEncoder().encode(model), let jsonData = try? JSON(data: data) {
113+
self = jsonData
112114
} else if let dictionary = object as? [String: Any] {
113115
self = JSON.dictionary(dictionary.mapValues { JSON($0) })
114116
} else if let array = object as? [Any] {
115117
self = JSON.array(array.map { JSON($0) })
116118
} else if let string = object as? String {
117119
self = JSON.string(string)
118-
} else if let bool = object as? Bool {
119-
self = JSON.bool(bool)
120120
} else if let number = object as? NSNumber {
121121
self = JSON.number(number)
122+
} else if let bool = object as? Bool {
123+
self = JSON.bool(bool)
122124
} else if let json = object as? JSON {
123125
self = json
124126
} else {

Sources/GoodNetworking/Models/NetworkResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// Wraps the payload returned from `URLSession` with
1111
/// metadata describing the HTTP response.
12-
public struct NetworkResponse {
12+
public struct NetworkResponse: Sendable {
1313

1414
/// Raw body returned by the server.
1515
public let body: Data

0 commit comments

Comments
 (0)