Since Alamofire 5 has now reached stable status, I would like to ask if and when swagger-codegen will use this for Swift 5 generated clients, as I absolutely need the RequestInterceptor module from Alamofire 5.
any luck with this? =)
same here
For a new project in which I plan to use Swagger-backed APIs, I too want to make use of Alamofire 5, so I did some digging. Here's what I found out so far.
Swift 5 support was added to swagger-codegen in version 3.0.17. When I started looking, version 3.0.18 had been released, and the templates were gone - or so I thought.
Turns out, the templates are now in a dedicated repository - in swagger-codegen-generators. You can find them in the directory src/main/resources/handlebars/swift5.
So I went ahead, and started to update the Podspec so that it requires Alamofire ~> 5.1.0. And since Alamofire 5 requires iOS 10, I increased the deployment target (which is also set in the Podspec) to iOS 10.
And that's when the actual work started. 馃槈
Bit by bit, I resolved the build errors using the Alamofire 5.0 Migration Guide, until my generated API client was building successfully.
I've pushed a branch (on my API client's repository) that shows the changes I made to the Podfile as well as to AlamofireImplementations.swift. (Just ignore the rest of the files that were changed - those are just from my API client.)
From the Swift 5 issue (#9386), I can tell that @plam4u has been working on this. Maybe he could take a look at my changes as well and see if they make sense.
Should I go ahead and create a PR in swagger-codegen-generators?
Thanks in advance for your feedback, and have a great weekend!
@wtimme thanks for the AlamofireImplementation.swift update.
I encountered one issue when expecting a Void type as return. In your implementation you expect responseData in line 354
case is Void.Type:
validatedRequest.responseData(completionHandler: { (voidResponse) in
This will lead to an Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength, as the server does not return anything.
This can be changed to
case is Void.Type:
validatedRequest.response(completionHandler: { (voidResponse) in
Any update on this?
Most helpful comment
For a new project in which I plan to use Swagger-backed APIs, I too want to make use of Alamofire 5, so I did some digging. Here's what I found out so far.
Swift 5 support was added to
swagger-codegenin version 3.0.17. When I started looking, version 3.0.18 had been released, and the templates were gone - or so I thought.Turns out, the templates are now in a dedicated repository - in
swagger-codegen-generators. You can find them in the directorysrc/main/resources/handlebars/swift5.So I went ahead, and started to update the Podspec so that it requires Alamofire
~> 5.1.0. And since Alamofire 5 requires iOS 10, I increased the deployment target (which is also set in the Podspec) to iOS 10.And that's when the actual work started. 馃槈
Bit by bit, I resolved the build errors using the Alamofire 5.0 Migration Guide, until my generated API client was building successfully.
I've pushed a branch (on my API client's repository) that shows the changes I made to the Podfile as well as to AlamofireImplementations.swift. (Just ignore the rest of the files that were changed - those are just from my API client.)
From the Swift 5 issue (#9386), I can tell that @plam4u has been working on this. Maybe he could take a look at my changes as well and see if they make sense.
Should I go ahead and create a PR in
swagger-codegen-generators?Thanks in advance for your feedback, and have a great weekend!