Skip to content

Commit ae1342c

Browse files
algolia-botFluf22
andcommitted
fix(swift): don't overwrite decimal encoding/decoding methods (generated)
algolia/api-clients-automation#4428 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 3c61175 commit ae1342c

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

Sources/Core/Helpers/Extensions.swift

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@ public extension KeyedEncodingContainerProtocol {
161161
try self.encodeMap(pairs)
162162
}
163163
}
164-
165-
mutating func encode(_ value: Decimal, forKey key: Self.Key) throws {
166-
var mutableValue = value
167-
let stringValue = NSDecimalString(&mutableValue, Locale(identifier: "en_US"))
168-
try self.encode(stringValue, forKey: key)
169-
}
170-
171-
mutating func encodeIfPresent(_ value: Decimal?, forKey key: Self.Key) throws {
172-
if let value {
173-
try self.encode(value, forKey: key)
174-
}
175-
}
176164
}
177165

178166
public extension KeyedDecodingContainerProtocol {
@@ -213,34 +201,6 @@ public extension KeyedDecodingContainerProtocol {
213201

214202
return map
215203
}
216-
217-
func decode(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal {
218-
let stringValue = try decode(String.self, forKey: key)
219-
guard let decimalValue = Decimal(string: stringValue) else {
220-
let context = DecodingError.Context(
221-
codingPath: [key],
222-
debugDescription: "The key \(key) couldn't be converted to a Decimal value"
223-
)
224-
throw DecodingError.typeMismatch(type, context)
225-
}
226-
227-
return decimalValue
228-
}
229-
230-
func decodeIfPresent(_ type: Decimal.Type, forKey key: Self.Key) throws -> Decimal? {
231-
guard let stringValue = try decodeIfPresent(String.self, forKey: key) else {
232-
return nil
233-
}
234-
guard let decimalValue = Decimal(string: stringValue) else {
235-
let context = DecodingError.Context(
236-
codingPath: [key],
237-
debugDescription: "The key \(key) couldn't be converted to a Decimal value"
238-
)
239-
throw DecodingError.typeMismatch(type, context)
240-
}
241-
242-
return decimalValue
243-
}
244204
}
245205

246206
extension HTTPURLResponse {

0 commit comments

Comments
 (0)