Open chaseacton opened 5 years ago
Not sure why that isn't working for you. The APIClient just uses sessionManager.request()
so anything past that is up to Alamofire.
Upon further investigation, the retrier isn't getting called on 401s because by default, they aren't considered errors. To make it work, .validate()
needs to be called on the request:
let networkRequest = sessionManager.request(urlRequest).validate().responseData(queue: decodingQueue)
Is this possible to do with SwagGen? .validate()
is called in swagger-codegen's implementation (https://github.com/swagger-api/swagger-codegen)
@yonaskolb As an alternative, it would be nice if RequestBehaviour had an additional protocol function to validate the response code/contents so we can tell SwagGen/Alamofire if the response should be treated as an error.
I had to modify the APIService to add .validate().
I am attempting to implement Alamofire's RequestRetrier and RequestAdapter protocols. The RequestAdapter works, but RequestRetrier doesn't;
func should(_ manager: SessionManager, retry request: Request, with error: Error, completion: @escaping RequestRetryCompletion)
is never called.I am setting them like this:
I've also tried: