[swift5] fix compile error from Alamofire 5.10 - cast Parameter type to avoid recursion (#19908)

* cast type to avoid unintended recursive call

* update samples
This commit is contained in:
Ryan Mustard 2024-10-18 09:58:14 -05:00 committed by GitHub
parent c6dbf0870c
commit 1248d7a103
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
let urlRequest = try urlRequest.asURLRequest()
return encode(urlRequest, with: parameters)
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
// cast this type so that the call to encode is not recursive
return encode(urlRequest, with: parameters as [String: Any]?)
}
}

View File

@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
let urlRequest = try urlRequest.asURLRequest()
return encode(urlRequest, with: parameters)
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
// cast this type so that the call to encode is not recursive
return encode(urlRequest, with: parameters as [String: Any]?)
}
}