swagger-api/swagger-codegen

swift codegen does not support query parameters on POST

Open

#1,564 建立於 2015年11月12日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)HTML (5,474 fork)batch import
Client: SwiftIssue: Bughelp wanted

倉庫指標

Star
 (12,701 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.

貢獻者指南