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
|
return destination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
let returnValues = values
|
let returnValues = values
|
||||||
.filter { $0.1 != nil }
|
.filter { $0.1 != nil }
|
||||||
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||||
URLQueryItem(name: item._key, value:"\(item._value!)")
|
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 {
|
if returnValues.count == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValues
|
return returnValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
|||||||
return destination
|
return destination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
let returnValues = values
|
let returnValues = values
|
||||||
.filter { $0.1 != nil }
|
.filter { $0.1 != nil }
|
||||||
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||||
URLQueryItem(name: item._key, value:"\(item._value!)")
|
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 {
|
if returnValues.count == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValues
|
return returnValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
|||||||
return destination
|
return destination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
let returnValues = values
|
let returnValues = values
|
||||||
.filter { $0.1 != nil }
|
.filter { $0.1 != nil }
|
||||||
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||||
URLQueryItem(name: item._key, value:"\(item._value!)")
|
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 {
|
if returnValues.count == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValues
|
return returnValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,16 +49,30 @@ class APIHelper {
|
|||||||
return destination
|
return destination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
static func mapValuesToQueryItems(values: [String:Any?]) -> [URLQueryItem]? {
|
||||||
let returnValues = values
|
let returnValues = values
|
||||||
.filter { $0.1 != nil }
|
.filter { $0.1 != nil }
|
||||||
.map { (item: (_key: String, _value: Any?)) -> URLQueryItem in
|
.map { (item: (_key: String, _value: Any?)) -> [URLQueryItem] in
|
||||||
URLQueryItem(name: item._key, value:"\(item._value!)")
|
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 {
|
if returnValues.count == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnValues
|
return returnValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user