Skip to content

Commit a571337

Browse files
feat(specs): recursive snippets and highlights result (generated)
algolia/api-clients-automation#3497 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 476f2d3 commit a571337

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Sources/Recommend/Models/RecommendHighlightResult.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import Foundation
77
#endif
88

99
public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable {
10+
case dictionaryOfStringToRecommendHighlightResult([String: RecommendHighlightResult])
1011
case recommendHighlightResultOption(RecommendHighlightResultOption)
1112
case dictionaryOfStringToRecommendHighlightResultOption([String: RecommendHighlightResultOption])
1213
case arrayOfRecommendHighlightResultOption([RecommendHighlightResultOption])
1314

1415
public func encode(to encoder: Encoder) throws {
1516
var container = encoder.singleValueContainer()
1617
switch self {
18+
case let .dictionaryOfStringToRecommendHighlightResult(value):
19+
try container.encode(value)
1720
case let .recommendHighlightResultOption(value):
1821
try container.encode(value)
1922
case let .dictionaryOfStringToRecommendHighlightResultOption(value):
@@ -25,7 +28,9 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable
2528

2629
public init(from decoder: Decoder) throws {
2730
let container = try decoder.singleValueContainer()
28-
if let value = try? container.decode(RecommendHighlightResultOption.self) {
31+
if let value = try? container.decode([String: RecommendHighlightResult].self) {
32+
self = .dictionaryOfStringToRecommendHighlightResult(value)
33+
} else if let value = try? container.decode(RecommendHighlightResultOption.self) {
2934
self = .recommendHighlightResultOption(value)
3035
} else if let value = try? container.decode([String: RecommendHighlightResultOption].self) {
3136
self = .dictionaryOfStringToRecommendHighlightResultOption(value)
@@ -44,6 +49,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable
4449

4550
public func GetActualInstance() -> Encodable {
4651
switch self {
52+
case let .dictionaryOfStringToRecommendHighlightResult(value):
53+
value as [String: RecommendHighlightResult]
4754
case let .recommendHighlightResultOption(value):
4855
value as RecommendHighlightResultOption
4956
case let .dictionaryOfStringToRecommendHighlightResultOption(value):

Sources/Recommend/Models/RecommendSnippetResult.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import Foundation
77
#endif
88

99
public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
10+
case dictionaryOfStringToRecommendSnippetResult([String: RecommendSnippetResult])
1011
case recommendSnippetResultOption(RecommendSnippetResultOption)
1112
case dictionaryOfStringToRecommendSnippetResultOption([String: RecommendSnippetResultOption])
1213
case arrayOfRecommendSnippetResultOption([RecommendSnippetResultOption])
1314

1415
public func encode(to encoder: Encoder) throws {
1516
var container = encoder.singleValueContainer()
1617
switch self {
18+
case let .dictionaryOfStringToRecommendSnippetResult(value):
19+
try container.encode(value)
1720
case let .recommendSnippetResultOption(value):
1821
try container.encode(value)
1922
case let .dictionaryOfStringToRecommendSnippetResultOption(value):
@@ -25,7 +28,9 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
2528

2629
public init(from decoder: Decoder) throws {
2730
let container = try decoder.singleValueContainer()
28-
if let value = try? container.decode(RecommendSnippetResultOption.self) {
31+
if let value = try? container.decode([String: RecommendSnippetResult].self) {
32+
self = .dictionaryOfStringToRecommendSnippetResult(value)
33+
} else if let value = try? container.decode(RecommendSnippetResultOption.self) {
2934
self = .recommendSnippetResultOption(value)
3035
} else if let value = try? container.decode([String: RecommendSnippetResultOption].self) {
3136
self = .dictionaryOfStringToRecommendSnippetResultOption(value)
@@ -44,6 +49,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
4449

4550
public func GetActualInstance() -> Encodable {
4651
switch self {
52+
case let .dictionaryOfStringToRecommendSnippetResult(value):
53+
value as [String: RecommendSnippetResult]
4754
case let .recommendSnippetResultOption(value):
4855
value as RecommendSnippetResultOption
4956
case let .dictionaryOfStringToRecommendSnippetResultOption(value):

Sources/Search/Models/SearchHighlightResult.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import Foundation
77
#endif
88

99
public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
10+
case dictionaryOfStringToSearchHighlightResult([String: SearchHighlightResult])
1011
case searchHighlightResultOption(SearchHighlightResultOption)
1112
case dictionaryOfStringToSearchHighlightResultOption([String: SearchHighlightResultOption])
1213
case arrayOfSearchHighlightResultOption([SearchHighlightResultOption])
1314

1415
public func encode(to encoder: Encoder) throws {
1516
var container = encoder.singleValueContainer()
1617
switch self {
18+
case let .dictionaryOfStringToSearchHighlightResult(value):
19+
try container.encode(value)
1720
case let .searchHighlightResultOption(value):
1821
try container.encode(value)
1922
case let .dictionaryOfStringToSearchHighlightResultOption(value):
@@ -25,7 +28,9 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
2528

2629
public init(from decoder: Decoder) throws {
2730
let container = try decoder.singleValueContainer()
28-
if let value = try? container.decode(SearchHighlightResultOption.self) {
31+
if let value = try? container.decode([String: SearchHighlightResult].self) {
32+
self = .dictionaryOfStringToSearchHighlightResult(value)
33+
} else if let value = try? container.decode(SearchHighlightResultOption.self) {
2934
self = .searchHighlightResultOption(value)
3035
} else if let value = try? container.decode([String: SearchHighlightResultOption].self) {
3136
self = .dictionaryOfStringToSearchHighlightResultOption(value)
@@ -44,6 +49,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
4449

4550
public func GetActualInstance() -> Encodable {
4651
switch self {
52+
case let .dictionaryOfStringToSearchHighlightResult(value):
53+
value as [String: SearchHighlightResult]
4754
case let .searchHighlightResultOption(value):
4855
value as SearchHighlightResultOption
4956
case let .dictionaryOfStringToSearchHighlightResultOption(value):

Sources/Search/Models/SearchSnippetResult.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import Foundation
77
#endif
88

99
public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {
10+
case dictionaryOfStringToSearchSnippetResult([String: SearchSnippetResult])
1011
case searchSnippetResultOption(SearchSnippetResultOption)
1112
case dictionaryOfStringToSearchSnippetResultOption([String: SearchSnippetResultOption])
1213
case arrayOfSearchSnippetResultOption([SearchSnippetResultOption])
1314

1415
public func encode(to encoder: Encoder) throws {
1516
var container = encoder.singleValueContainer()
1617
switch self {
18+
case let .dictionaryOfStringToSearchSnippetResult(value):
19+
try container.encode(value)
1720
case let .searchSnippetResultOption(value):
1821
try container.encode(value)
1922
case let .dictionaryOfStringToSearchSnippetResultOption(value):
@@ -25,7 +28,9 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {
2528

2629
public init(from decoder: Decoder) throws {
2730
let container = try decoder.singleValueContainer()
28-
if let value = try? container.decode(SearchSnippetResultOption.self) {
31+
if let value = try? container.decode([String: SearchSnippetResult].self) {
32+
self = .dictionaryOfStringToSearchSnippetResult(value)
33+
} else if let value = try? container.decode(SearchSnippetResultOption.self) {
2934
self = .searchSnippetResultOption(value)
3035
} else if let value = try? container.decode([String: SearchSnippetResultOption].self) {
3136
self = .dictionaryOfStringToSearchSnippetResultOption(value)
@@ -44,6 +49,8 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {
4449

4550
public func GetActualInstance() -> Encodable {
4651
switch self {
52+
case let .dictionaryOfStringToSearchSnippetResult(value):
53+
value as [String: SearchSnippetResult]
4754
case let .searchSnippetResultOption(value):
4855
value as SearchSnippetResultOption
4956
case let .dictionaryOfStringToSearchSnippetResultOption(value):

0 commit comments

Comments
 (0)