Skip to content

Commit 1248d7a

Browse files
authoredOct 18, 2024··
[swift5] fix compile error from Alamofire 5.10 - cast Parameter type to avoid recursion (#19908)
* cast type to avoid unintended recursive call * update samples
1 parent c6dbf08 commit 1248d7a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache

+3-1
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
408408
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
409409
let urlRequest = try urlRequest.asURLRequest()
410410
411-
return encode(urlRequest, with: parameters)
411+
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
412+
// cast this type so that the call to encode is not recursive
413+
return encode(urlRequest, with: parameters as [String: Any]?)
412414
}
413415
}

‎samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ extension JSONDataEncoding: ParameterEncoding {
408408
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
409409
let urlRequest = try urlRequest.asURLRequest()
410410

411-
return encode(urlRequest, with: parameters)
411+
// Alamofire 5.10 changed type of Parameters so that it is no longer equivalent to [String: Any]
412+
// cast this type so that the call to encode is not recursive
413+
return encode(urlRequest, with: parameters as [String: Any]?)
412414
}
413415
}

0 commit comments

Comments
 (0)
Please sign in to comment.