forked from loafle/openapi-generator-original
[Swift3] Fix handling of query item with array value (#5684)
This commit is contained in:
parent
022eb0d379
commit
ef8365ecd2
@ -49,16 +49,30 @@ class APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
|
||||
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!)")
|
||||
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||
if let value = item._value as? Array<String> {
|
||||
return value.map { (v) -> URLQueryItem in
|
||||
URLQueryItem(
|
||||
name: item._key,
|
||||
value: v
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return [URLQueryItem(
|
||||
name: item._key,
|
||||
value: "\(item._value!)"
|
||||
)]
|
||||
}
|
||||
}
|
||||
.flatMap { $0 }
|
||||
|
||||
if returnValues.count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return returnValues
|
||||
}
|
||||
|
||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
|
||||
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!)")
|
||||
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||
if let value = item._value as? Array<String> {
|
||||
return value.map { (v) -> URLQueryItem in
|
||||
URLQueryItem(
|
||||
name: item._key,
|
||||
value: v
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return [URLQueryItem(
|
||||
name: item._key,
|
||||
value: "\(item._value!)"
|
||||
)]
|
||||
}
|
||||
}
|
||||
.flatMap { $0 }
|
||||
|
||||
if returnValues.count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return returnValues
|
||||
}
|
||||
|
||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
|
||||
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!)")
|
||||
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||
if let value = item._value as? Array<String> {
|
||||
return value.map { (v) -> URLQueryItem in
|
||||
URLQueryItem(
|
||||
name: item._key,
|
||||
value: v
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return [URLQueryItem(
|
||||
name: item._key,
|
||||
value: "\(item._value!)"
|
||||
)]
|
||||
}
|
||||
}
|
||||
.flatMap { $0 }
|
||||
|
||||
if returnValues.count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return returnValues
|
||||
}
|
||||
|
||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
|
||||
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!)")
|
||||
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||
if let value = item._value as? Array<String> {
|
||||
return value.map { (v) -> URLQueryItem in
|
||||
URLQueryItem(
|
||||
name: item._key,
|
||||
value: v
|
||||
)
|
||||
}
|
||||
} else {
|
||||
return [URLQueryItem(
|
||||
name: item._key,
|
||||
value: "\(item._value!)"
|
||||
)]
|
||||
}
|
||||
}
|
||||
.flatMap { $0 }
|
||||
|
||||
if returnValues.count == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return returnValues
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user