fix: HeaderParameterEncoding array encoding

This commit is contained in:
Ivan Smolin 2022-03-30 20:16:33 +03:00
parent 8a482cc186
commit 11f6b5dbd0
12 changed files with 35 additions and 12 deletions

View File

@ -1,5 +1,9 @@
# Changelog
### 1.12.2
- **Fix**: HeaderParameterEncoding encodes array correctly
### 1.12.1
- **Update**: DefaultRecoverableNetworkService `request` parameter was renamed to prevent ambgious reference

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKit"
s.version = "1.12.1"
s.version = "1.12.2"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKit"
s.license = "Apache License, Version 2.0"

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIFoundationUtils'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Set of helpers for Foundation framework classes.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIKeychainUtils'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Set of helpers for Keychain classes.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIMoyaNetworking'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Moya + Swagger network service.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -20,10 +20,29 @@
// THE SOFTWARE.
//
open class HeaderParameterEncoding: BaseUrlParameterEncoding, ParameterEncoding {
open class HeaderParameterEncoding: ParameterEncoding {
// MARK: - ParameterEncoding
open func encode(parameters: [String: Parameter<LocationHeader>]) -> [String: String] {
return Dictionary(uniqueKeysWithValues: super.encode(parameters: parameters))
parameters.reduce(into: [:]) {
$0.merge(pathComponents(fromKey: $1.key, value: $1.value)) { _, last in last }
}
}
open func pathComponents(fromKey key: String, value: Any) -> [String: String] {
var components: [String: String] = [:]
switch value {
case let dictionary as [String: Any]:
for (nestedKey, value) in dictionary {
components.merge(pathComponents(fromKey: nestedKey, value: value)) { _, last in last }
}
case let array as [Any]:
components.updateValue(array.map { "\($0)" }.joined(separator: ","), forKey: key)
default:
components.updateValue("\(value)", forKey: key)
}
return components
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TINetworking'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Swagger-frendly networking layer helpers.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TISwiftUtils'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Bunch of useful helpers for Swift development.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TITableKitUtils'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Set of helpers for TableKit classes.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TITransitions'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Set of custom transitions to present controller. '
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIUIElements'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Bunch of useful protocols and views.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIUIKitCore'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = 'Core UI elements: protocols, views and helpers.'
s.homepage = 'https://github.com/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }