diff --git a/Sources/Recommend/Models/RecommendHighlightResult.swift b/Sources/Recommend/Models/RecommendHighlightResult.swift index 321b6f2b..d87c28a0 100644 --- a/Sources/Recommend/Models/RecommendHighlightResult.swift +++ b/Sources/Recommend/Models/RecommendHighlightResult.swift @@ -7,6 +7,7 @@ import Foundation #endif public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable { + case dictionaryOfStringToRecommendHighlightResult([String: RecommendHighlightResult]) case recommendHighlightResultOption(RecommendHighlightResultOption) case dictionaryOfStringToRecommendHighlightResultOption([String: RecommendHighlightResultOption]) case arrayOfRecommendHighlightResultOption([RecommendHighlightResultOption]) @@ -14,6 +15,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { + case let .dictionaryOfStringToRecommendHighlightResult(value): + try container.encode(value) case let .recommendHighlightResultOption(value): try container.encode(value) case let .dictionaryOfStringToRecommendHighlightResultOption(value): @@ -25,7 +28,9 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(RecommendHighlightResultOption.self) { + if let value = try? container.decode([String: RecommendHighlightResult].self) { + self = .dictionaryOfStringToRecommendHighlightResult(value) + } else if let value = try? container.decode(RecommendHighlightResultOption.self) { self = .recommendHighlightResultOption(value) } else if let value = try? container.decode([String: RecommendHighlightResultOption].self) { self = .dictionaryOfStringToRecommendHighlightResultOption(value) @@ -44,6 +49,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable public func GetActualInstance() -> Encodable { switch self { + case let .dictionaryOfStringToRecommendHighlightResult(value): + value as [String: RecommendHighlightResult] case let .recommendHighlightResultOption(value): value as RecommendHighlightResultOption case let .dictionaryOfStringToRecommendHighlightResultOption(value): diff --git a/Sources/Recommend/Models/RecommendSnippetResult.swift b/Sources/Recommend/Models/RecommendSnippetResult.swift index ff87ed63..6ed63010 100644 --- a/Sources/Recommend/Models/RecommendSnippetResult.swift +++ b/Sources/Recommend/Models/RecommendSnippetResult.swift @@ -7,6 +7,7 @@ import Foundation #endif public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable { + case dictionaryOfStringToRecommendSnippetResult([String: RecommendSnippetResult]) case recommendSnippetResultOption(RecommendSnippetResultOption) case dictionaryOfStringToRecommendSnippetResultOption([String: RecommendSnippetResultOption]) case arrayOfRecommendSnippetResultOption([RecommendSnippetResultOption]) @@ -14,6 +15,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { + case let .dictionaryOfStringToRecommendSnippetResult(value): + try container.encode(value) case let .recommendSnippetResultOption(value): try container.encode(value) case let .dictionaryOfStringToRecommendSnippetResultOption(value): @@ -25,7 +28,9 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(RecommendSnippetResultOption.self) { + if let value = try? container.decode([String: RecommendSnippetResult].self) { + self = .dictionaryOfStringToRecommendSnippetResult(value) + } else if let value = try? container.decode(RecommendSnippetResultOption.self) { self = .recommendSnippetResultOption(value) } else if let value = try? container.decode([String: RecommendSnippetResultOption].self) { self = .dictionaryOfStringToRecommendSnippetResultOption(value) @@ -44,6 +49,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable { public func GetActualInstance() -> Encodable { switch self { + case let .dictionaryOfStringToRecommendSnippetResult(value): + value as [String: RecommendSnippetResult] case let .recommendSnippetResultOption(value): value as RecommendSnippetResultOption case let .dictionaryOfStringToRecommendSnippetResultOption(value): diff --git a/Sources/Search/Models/SearchHighlightResult.swift b/Sources/Search/Models/SearchHighlightResult.swift index e28e710a..eb3592eb 100644 --- a/Sources/Search/Models/SearchHighlightResult.swift +++ b/Sources/Search/Models/SearchHighlightResult.swift @@ -7,6 +7,7 @@ import Foundation #endif public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable { + case dictionaryOfStringToSearchHighlightResult([String: SearchHighlightResult]) case searchHighlightResultOption(SearchHighlightResultOption) case dictionaryOfStringToSearchHighlightResultOption([String: SearchHighlightResultOption]) case arrayOfSearchHighlightResultOption([SearchHighlightResultOption]) @@ -14,6 +15,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { + case let .dictionaryOfStringToSearchHighlightResult(value): + try container.encode(value) case let .searchHighlightResultOption(value): try container.encode(value) case let .dictionaryOfStringToSearchHighlightResultOption(value): @@ -25,7 +28,9 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(SearchHighlightResultOption.self) { + if let value = try? container.decode([String: SearchHighlightResult].self) { + self = .dictionaryOfStringToSearchHighlightResult(value) + } else if let value = try? container.decode(SearchHighlightResultOption.self) { self = .searchHighlightResultOption(value) } else if let value = try? container.decode([String: SearchHighlightResultOption].self) { self = .dictionaryOfStringToSearchHighlightResultOption(value) @@ -44,6 +49,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable { public func GetActualInstance() -> Encodable { switch self { + case let .dictionaryOfStringToSearchHighlightResult(value): + value as [String: SearchHighlightResult] case let .searchHighlightResultOption(value): value as SearchHighlightResultOption case let .dictionaryOfStringToSearchHighlightResultOption(value): diff --git a/Sources/Search/Models/SearchSnippetResult.swift b/Sources/Search/Models/SearchSnippetResult.swift index ad775fcb..2d073f3f 100644 --- a/Sources/Search/Models/SearchSnippetResult.swift +++ b/Sources/Search/Models/SearchSnippetResult.swift @@ -7,6 +7,7 @@ import Foundation #endif public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable { + case dictionaryOfStringToSearchSnippetResult([String: SearchSnippetResult]) case searchSnippetResultOption(SearchSnippetResultOption) case dictionaryOfStringToSearchSnippetResultOption([String: SearchSnippetResultOption]) case arrayOfSearchSnippetResultOption([SearchSnippetResultOption]) @@ -14,6 +15,8 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { + case let .dictionaryOfStringToSearchSnippetResult(value): + try container.encode(value) case let .searchSnippetResultOption(value): try container.encode(value) case let .dictionaryOfStringToSearchSnippetResultOption(value): @@ -25,7 +28,9 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() - if let value = try? container.decode(SearchSnippetResultOption.self) { + if let value = try? container.decode([String: SearchSnippetResult].self) { + self = .dictionaryOfStringToSearchSnippetResult(value) + } else if let value = try? container.decode(SearchSnippetResultOption.self) { self = .searchSnippetResultOption(value) } else if let value = try? container.decode([String: SearchSnippetResultOption].self) { self = .dictionaryOfStringToSearchSnippetResultOption(value) @@ -44,6 +49,8 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable { public func GetActualInstance() -> Encodable { switch self { + case let .dictionaryOfStringToSearchSnippetResult(value): + value as [String: SearchSnippetResult] case let .searchSnippetResultOption(value): value as SearchSnippetResultOption case let .dictionaryOfStringToSearchSnippetResultOption(value):