-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Swift3] Request body cannot be an array, only a dictionary #5480
Comments
@davidpasztor thanks for reporting the issue. When you've time, I wonder if you can try the 2.3.0 branch to generate Swift3 API client, which contains some enhancements (breaking changes), to see if the same issue still occurs. |
@wing328 I have tried the 2.3.0 branch and sadly the issue still exists. The implementation of the function mentioned in my issue has not been changed and hence the issue has not been resolved in the 2.3.0 branch. |
@davidpasztor I had this issue as well. To solve this and whole bunch of others I ended up writing a whole new generator in and for Swift here https://github.com/yonaskolb/SwagGen |
@yonaskolb I finally managed to have a look at the code generated by SwagGen and it indeed looks like it solved this issue, however I had another issue with Swagger Codegen, which doesn't seem to be tackled by SwagGen either. For details please check #5452 |
cc @RobBlairInq @jgavris @jaz-ah to review the issue. |
Description
The request body cannot be an array of dictionaries, or in fact an array of any object, it can only be a dictionary (which can be a dictionary containing other dictionaries as values).
The issue comes from the Alamofire implementation that the request body is converted from the query parameters and the query parameters have to be a dictionary and cannot be an array.
Swagger-codegen version
2.2.2
Swagger declaration file content or url
Command line used for generation
swagger-codegen generate -i /path/spec.yaml -l swift3
Steps to reproduce
Generate a Swift3 client side code from a swagger spec that contains type: array in its schema for an object that is in:body.
Related issues
#2483
#4490
Suggest a Fix
The Swift file API.swift generated by swagger-codegen has the following method:
The problem comes from the fact that there is no body input parameter for the initialiser, only the isBody Bool, which makes it impossible �to have a query parameter and a request body of different types. This is an issue, since quite a few APIs expect an array of values as the body of the request, which is not possible with the current implementation.
The text was updated successfully, but these errors were encountered: