Open jrcmramos opened 5 years ago
I hit the same issue, how to fix!? any workaround??
As far as I am concerned, we cannot use another Alamofire client without touching the existing template or creating a new one.
i have done a quick fix for that in my pull request https://github.com/swagger-api/swagger-codegen/pull/9499
Description
The current Alamofire client template implementation does not support concurrent requests. The static
AlamofireRequestBuilder.execute
method adds an instance ofAlamofire.SessionManager
to a global variable (managerStore
) without any thread safe mechanism to avoid concurrent accesses. Therefore this can result, for example, in the deallocation of aAlamofire.SessionManager
that might cancel the request. As result, the requests affect will returnError Domain=NSURLErrorDomain Code=-999 "cancelled"
.Swagger-codegen version
2.3.1
,3.0.5
Swagger declaration file content or url
Not needed, all applications making concurrent requests using the Alamofire implementation of these version should experience the same issues.
Command line used for generation
swagger-codegen-2.3.1 generate -i http://localhost:8083/api-docs/v1/swagger.json -l swift4 -o swagger-client
Steps to reproduce
Dispatch several concurrent operation to a
OperationQueue
performing different API requests. Check if any of these calls resulted in a cancelled request.Suggest a fix/enhancement
I can think about two different solutions that could help in the resolution of this problem:
Make the global variable thread safe. We could use something like this: