Open tigaris opened 9 years ago
@tigaris I am a newer can you please give your email to me I want to ask how to use the swift code that be generated by codegen. Thank you
+1 I encountered the same problem.
A good starting point for the fix is https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache#L31.
If anyone from the community has cycle to contribute the fix, please reply to let us know.
I think the starting point for the fix is: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/swift/api.mustache
the {#allParams} is unused if there is an body parameter in this case they should be added to the URL or im am wrong ?
@AMiketta do you mind submitting a PR so that we can more easily review the fix?
{{#allParams}} stores all the parameters (query, form, body, etc) so using it to obtain the query parameters is a good starting point.
cc @jaz-ah @Edubits
Is there any work on this currently?
POST methods with query parameter types map to Alamofire.ParameterEncoding.URL which means they are sent in the body of the request as application/x-www-form-urlencoded.
I need to support POST methods with query parameter types that map to Alamofire.ParameterEncoding.URLEncodedInURL. The generated code does not make it easy to support this due to its use of a boolean flag isBody, rather than an enumeration.
The following line in AlamofireImplementations.swift within the execute method is the issue:
let encoding = isBody ? Alamofire.ParameterEncoding.JSON : Alamofire.ParameterEncoding.URL
I believe the solution would be to refactor the isBody variable away in favor of an explicit ParameterEncoding type enum. This would make it easy to override the encoding behavior at the individual method level.