forked from loafle/openapi-generator-original
[Swift] two fixes to latest param mapping code (#4587)
* two fixes: 1) extra ?'s at end of some url's 2) enums not being called out w/ rawValue to get the proper string name * update samples * one step closer * closer implementation
This commit is contained in:
@@ -40,12 +40,16 @@ class APIHelper {
|
||||
}
|
||||
|
||||
|
||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem] {
|
||||
return values
|
||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||
let returnValues = values
|
||||
.filter { $0.1 != nil }
|
||||
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
||||
URLQueryItem(name: item._key, value:"\(item._value!)")
|
||||
}
|
||||
if returnValues.count == 0 {
|
||||
return nil
|
||||
}
|
||||
return returnValues
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ open class {{classname}}: APIBase {
|
||||
let url = NSURLComponents(string: URLString)
|
||||
{{#hasQueryParams}}
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
|
||||
{{#queryParams}}
|
||||
"{{paramName}}": {{paramName}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/queryParams}}
|
||||
{{#queryParams}}
|
||||
{{> _param}}{{#hasMore}}, {{/hasMore}}
|
||||
{{/queryParams}}
|
||||
])
|
||||
{{/hasQueryParams}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user