Skip to content

Commit 22be7b8

Browse files
algolia-botFluf22
andcommitted
fix(specs): update search api specs [skip-bc] (generated)
algolia/api-clients-automation#3760 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 8d237bd commit 22be7b8

8 files changed

+94
-130
lines changed

Sources/Recommend/Models/RecommendHighlightResult.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import Foundation
99
public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable {
1010
case recommendHighlightResultOption(RecommendHighlightResultOption)
1111
case dictionaryOfStringToRecommendHighlightResult([String: RecommendHighlightResult])
12-
case dictionaryOfStringToRecommendHighlightResultOption([String: RecommendHighlightResultOption])
13-
case arrayOfRecommendHighlightResultOption([RecommendHighlightResultOption])
12+
case arrayOfRecommendHighlightResult([RecommendHighlightResult])
1413

1514
public func encode(to encoder: Encoder) throws {
1615
var container = encoder.singleValueContainer()
@@ -19,9 +18,7 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable
1918
try container.encode(value)
2019
case let .dictionaryOfStringToRecommendHighlightResult(value):
2120
try container.encode(value)
22-
case let .dictionaryOfStringToRecommendHighlightResultOption(value):
23-
try container.encode(value)
24-
case let .arrayOfRecommendHighlightResultOption(value):
21+
case let .arrayOfRecommendHighlightResult(value):
2522
try container.encode(value)
2623
}
2724
}
@@ -32,10 +29,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable
3229
self = .recommendHighlightResultOption(value)
3330
} else if let value = try? container.decode([String: RecommendHighlightResult].self) {
3431
self = .dictionaryOfStringToRecommendHighlightResult(value)
35-
} else if let value = try? container.decode([String: RecommendHighlightResultOption].self) {
36-
self = .dictionaryOfStringToRecommendHighlightResultOption(value)
37-
} else if let value = try? container.decode([RecommendHighlightResultOption].self) {
38-
self = .arrayOfRecommendHighlightResultOption(value)
32+
} else if let value = try? container.decode([RecommendHighlightResult].self) {
33+
self = .arrayOfRecommendHighlightResult(value)
3934
} else {
4035
throw DecodingError.typeMismatch(
4136
Self.Type.self,
@@ -53,10 +48,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable
5348
value as RecommendHighlightResultOption
5449
case let .dictionaryOfStringToRecommendHighlightResult(value):
5550
value as [String: RecommendHighlightResult]
56-
case let .dictionaryOfStringToRecommendHighlightResultOption(value):
57-
value as [String: RecommendHighlightResultOption]
58-
case let .arrayOfRecommendHighlightResultOption(value):
59-
value as [RecommendHighlightResultOption]
51+
case let .arrayOfRecommendHighlightResult(value):
52+
value as [RecommendHighlightResult]
6053
}
6154
}
6255
}

Sources/Recommend/Models/RecommendSearchPagination.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import Foundation
88

99
public struct RecommendSearchPagination: Codable, JSONEncodable {
1010
/// Page of search results to retrieve.
11-
public var page: Int
11+
public var page: Int?
1212
/// Number of results (hits).
13-
public var nbHits: Int
13+
public var nbHits: Int?
1414
/// Number of pages of results.
15-
public var nbPages: Int
15+
public var nbPages: Int?
1616
/// Number of hits per page.
17-
public var hitsPerPage: Int
17+
public var hitsPerPage: Int?
1818

19-
public init(page: Int, nbHits: Int, nbPages: Int, hitsPerPage: Int) {
19+
public init(page: Int? = nil, nbHits: Int? = nil, nbPages: Int? = nil, hitsPerPage: Int? = nil) {
2020
self.page = page
2121
self.nbHits = nbHits
2222
self.nbPages = nbPages
@@ -34,10 +34,10 @@ public struct RecommendSearchPagination: Codable, JSONEncodable {
3434

3535
public func encode(to encoder: Encoder) throws {
3636
var container = encoder.container(keyedBy: CodingKeys.self)
37-
try container.encode(self.page, forKey: .page)
38-
try container.encode(self.nbHits, forKey: .nbHits)
39-
try container.encode(self.nbPages, forKey: .nbPages)
40-
try container.encode(self.hitsPerPage, forKey: .hitsPerPage)
37+
try container.encodeIfPresent(self.page, forKey: .page)
38+
try container.encodeIfPresent(self.nbHits, forKey: .nbHits)
39+
try container.encodeIfPresent(self.nbPages, forKey: .nbPages)
40+
try container.encodeIfPresent(self.hitsPerPage, forKey: .hitsPerPage)
4141
}
4242
}
4343

@@ -52,9 +52,9 @@ extension RecommendSearchPagination: Equatable {
5252

5353
extension RecommendSearchPagination: Hashable {
5454
public func hash(into hasher: inout Hasher) {
55-
hasher.combine(self.page.hashValue)
56-
hasher.combine(self.nbHits.hashValue)
57-
hasher.combine(self.nbPages.hashValue)
58-
hasher.combine(self.hitsPerPage.hashValue)
55+
hasher.combine(self.page?.hashValue)
56+
hasher.combine(self.nbHits?.hashValue)
57+
hasher.combine(self.nbPages?.hashValue)
58+
hasher.combine(self.hitsPerPage?.hashValue)
5959
}
6060
}

Sources/Recommend/Models/RecommendSnippetResult.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import Foundation
99
public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
1010
case recommendSnippetResultOption(RecommendSnippetResultOption)
1111
case dictionaryOfStringToRecommendSnippetResult([String: RecommendSnippetResult])
12-
case dictionaryOfStringToRecommendSnippetResultOption([String: RecommendSnippetResultOption])
13-
case arrayOfRecommendSnippetResultOption([RecommendSnippetResultOption])
12+
case arrayOfRecommendSnippetResult([RecommendSnippetResult])
1413

1514
public func encode(to encoder: Encoder) throws {
1615
var container = encoder.singleValueContainer()
@@ -19,9 +18,7 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
1918
try container.encode(value)
2019
case let .dictionaryOfStringToRecommendSnippetResult(value):
2120
try container.encode(value)
22-
case let .dictionaryOfStringToRecommendSnippetResultOption(value):
23-
try container.encode(value)
24-
case let .arrayOfRecommendSnippetResultOption(value):
21+
case let .arrayOfRecommendSnippetResult(value):
2522
try container.encode(value)
2623
}
2724
}
@@ -32,10 +29,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
3229
self = .recommendSnippetResultOption(value)
3330
} else if let value = try? container.decode([String: RecommendSnippetResult].self) {
3431
self = .dictionaryOfStringToRecommendSnippetResult(value)
35-
} else if let value = try? container.decode([String: RecommendSnippetResultOption].self) {
36-
self = .dictionaryOfStringToRecommendSnippetResultOption(value)
37-
} else if let value = try? container.decode([RecommendSnippetResultOption].self) {
38-
self = .arrayOfRecommendSnippetResultOption(value)
32+
} else if let value = try? container.decode([RecommendSnippetResult].self) {
33+
self = .arrayOfRecommendSnippetResult(value)
3934
} else {
4035
throw DecodingError.typeMismatch(
4136
Self.Type.self,
@@ -53,10 +48,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
5348
value as RecommendSnippetResultOption
5449
case let .dictionaryOfStringToRecommendSnippetResult(value):
5550
value as [String: RecommendSnippetResult]
56-
case let .dictionaryOfStringToRecommendSnippetResultOption(value):
57-
value as [String: RecommendSnippetResultOption]
58-
case let .arrayOfRecommendSnippetResultOption(value):
59-
value as [RecommendSnippetResultOption]
51+
case let .arrayOfRecommendSnippetResult(value):
52+
value as [RecommendSnippetResult]
6053
}
6154
}
6255
}

Sources/Recommend/Models/RecommendationsResults.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public struct RecommendationsResults: Codable, JSONEncodable {
6161
/// Whether automatic events collection is enabled for the application.
6262
public var automaticInsights: Bool?
6363
/// Page of search results to retrieve.
64-
public var page: Int
64+
public var page: Int?
6565
/// Number of results (hits).
66-
public var nbHits: Int
66+
public var nbHits: Int?
6767
/// Number of pages of results.
68-
public var nbPages: Int
68+
public var nbPages: Int?
6969
/// Number of hits per page.
70-
public var hitsPerPage: Int
70+
public var hitsPerPage: Int?
7171
public var hits: [RecommendationsHit]
7272

7373
public init(
@@ -96,10 +96,10 @@ public struct RecommendationsResults: Codable, JSONEncodable {
9696
userData: AnyCodable? = nil,
9797
queryID: String? = nil,
9898
automaticInsights: Bool? = nil,
99-
page: Int,
100-
nbHits: Int,
101-
nbPages: Int,
102-
hitsPerPage: Int,
99+
page: Int? = nil,
100+
nbHits: Int? = nil,
101+
nbPages: Int? = nil,
102+
hitsPerPage: Int? = nil,
103103
hits: [RecommendationsHit]
104104
) {
105105
self.abTestID = abTestID
@@ -196,10 +196,10 @@ public struct RecommendationsResults: Codable, JSONEncodable {
196196
try container.encodeIfPresent(self.userData, forKey: .userData)
197197
try container.encodeIfPresent(self.queryID, forKey: .queryID)
198198
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
199-
try container.encode(self.page, forKey: .page)
200-
try container.encode(self.nbHits, forKey: .nbHits)
201-
try container.encode(self.nbPages, forKey: .nbPages)
202-
try container.encode(self.hitsPerPage, forKey: .hitsPerPage)
199+
try container.encodeIfPresent(self.page, forKey: .page)
200+
try container.encodeIfPresent(self.nbHits, forKey: .nbHits)
201+
try container.encodeIfPresent(self.nbPages, forKey: .nbPages)
202+
try container.encodeIfPresent(self.hitsPerPage, forKey: .hitsPerPage)
203203
try container.encode(self.hits, forKey: .hits)
204204
}
205205
}
@@ -266,10 +266,10 @@ extension RecommendationsResults: Hashable {
266266
hasher.combine(self.userData?.hashValue)
267267
hasher.combine(self.queryID?.hashValue)
268268
hasher.combine(self.automaticInsights?.hashValue)
269-
hasher.combine(self.page.hashValue)
270-
hasher.combine(self.nbHits.hashValue)
271-
hasher.combine(self.nbPages.hashValue)
272-
hasher.combine(self.hitsPerPage.hashValue)
269+
hasher.combine(self.page?.hashValue)
270+
hasher.combine(self.nbHits?.hashValue)
271+
hasher.combine(self.nbPages?.hashValue)
272+
hasher.combine(self.hitsPerPage?.hashValue)
273273
hasher.combine(self.hits.hashValue)
274274
}
275275
}

Sources/Search/Models/SearchHighlightResult.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import Foundation
99
public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
1010
case searchHighlightResultOption(SearchHighlightResultOption)
1111
case dictionaryOfStringToSearchHighlightResult([String: SearchHighlightResult])
12-
case dictionaryOfStringToSearchHighlightResultOption([String: SearchHighlightResultOption])
13-
case arrayOfSearchHighlightResultOption([SearchHighlightResultOption])
12+
case arrayOfSearchHighlightResult([SearchHighlightResult])
1413

1514
public func encode(to encoder: Encoder) throws {
1615
var container = encoder.singleValueContainer()
@@ -19,9 +18,7 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
1918
try container.encode(value)
2019
case let .dictionaryOfStringToSearchHighlightResult(value):
2120
try container.encode(value)
22-
case let .dictionaryOfStringToSearchHighlightResultOption(value):
23-
try container.encode(value)
24-
case let .arrayOfSearchHighlightResultOption(value):
21+
case let .arrayOfSearchHighlightResult(value):
2522
try container.encode(value)
2623
}
2724
}
@@ -32,10 +29,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
3229
self = .searchHighlightResultOption(value)
3330
} else if let value = try? container.decode([String: SearchHighlightResult].self) {
3431
self = .dictionaryOfStringToSearchHighlightResult(value)
35-
} else if let value = try? container.decode([String: SearchHighlightResultOption].self) {
36-
self = .dictionaryOfStringToSearchHighlightResultOption(value)
37-
} else if let value = try? container.decode([SearchHighlightResultOption].self) {
38-
self = .arrayOfSearchHighlightResultOption(value)
32+
} else if let value = try? container.decode([SearchHighlightResult].self) {
33+
self = .arrayOfSearchHighlightResult(value)
3934
} else {
4035
throw DecodingError.typeMismatch(
4136
Self.Type.self,
@@ -53,10 +48,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
5348
value as SearchHighlightResultOption
5449
case let .dictionaryOfStringToSearchHighlightResult(value):
5550
value as [String: SearchHighlightResult]
56-
case let .dictionaryOfStringToSearchHighlightResultOption(value):
57-
value as [String: SearchHighlightResultOption]
58-
case let .arrayOfSearchHighlightResultOption(value):
59-
value as [SearchHighlightResultOption]
51+
case let .arrayOfSearchHighlightResult(value):
52+
value as [SearchHighlightResult]
6053
}
6154
}
6255
}

Sources/Search/Models/SearchResponse.swift

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
6161
/// Whether automatic events collection is enabled for the application.
6262
public var automaticInsights: Bool?
6363
/// Page of search results to retrieve.
64-
public var page: Int
64+
public var page: Int?
6565
/// Number of results (hits).
66-
public var nbHits: Int
66+
public var nbHits: Int?
6767
/// Number of pages of results.
68-
public var nbPages: Int
68+
public var nbPages: Int?
6969
/// Number of hits per page.
70-
public var hitsPerPage: Int
70+
public var hitsPerPage: Int?
7171
/// Search results (hits). Hits are records from your index that match the search criteria, augmented with
7272
/// additional attributes, such as, for highlighting.
7373
public var hits: [T]
@@ -102,10 +102,10 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
102102
userData: AnyCodable? = nil,
103103
queryID: String? = nil,
104104
automaticInsights: Bool? = nil,
105-
page: Int,
106-
nbHits: Int,
107-
nbPages: Int,
108-
hitsPerPage: Int,
105+
page: Int? = nil,
106+
nbHits: Int? = nil,
107+
nbPages: Int? = nil,
108+
hitsPerPage: Int? = nil,
109109
hits: [T],
110110
query: String,
111111
params: String
@@ -247,22 +247,14 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
247247

248248
self.automaticInsights = dictionary["automaticInsights"]?.value as? Bool
249249

250-
guard let page = dictionary["page"]?.value as? Int else {
251-
throw GenericError(description: "Failed to cast")
252-
}
253-
self.page = page
254-
guard let nbHits = dictionary["nbHits"]?.value as? Int else {
255-
throw GenericError(description: "Failed to cast")
256-
}
257-
self.nbHits = nbHits
258-
guard let nbPages = dictionary["nbPages"]?.value as? Int else {
259-
throw GenericError(description: "Failed to cast")
260-
}
261-
self.nbPages = nbPages
262-
guard let hitsPerPage = dictionary["hitsPerPage"]?.value as? Int else {
263-
throw GenericError(description: "Failed to cast")
264-
}
265-
self.hitsPerPage = hitsPerPage
250+
self.page = dictionary["page"]?.value as? Int
251+
252+
self.nbHits = dictionary["nbHits"]?.value as? Int
253+
254+
self.nbPages = dictionary["nbPages"]?.value as? Int
255+
256+
self.hitsPerPage = dictionary["hitsPerPage"]?.value as? Int
257+
266258
guard let hits = dictionary["hits"]?.value as? [T] else {
267259
throw GenericError(description: "Failed to cast")
268260
}
@@ -318,10 +310,10 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
318310
try container.encodeIfPresent(self.userData, forKey: .userData)
319311
try container.encodeIfPresent(self.queryID, forKey: .queryID)
320312
try container.encodeIfPresent(self.automaticInsights, forKey: .automaticInsights)
321-
try container.encode(self.page, forKey: .page)
322-
try container.encode(self.nbHits, forKey: .nbHits)
323-
try container.encode(self.nbPages, forKey: .nbPages)
324-
try container.encode(self.hitsPerPage, forKey: .hitsPerPage)
313+
try container.encodeIfPresent(self.page, forKey: .page)
314+
try container.encodeIfPresent(self.nbHits, forKey: .nbHits)
315+
try container.encodeIfPresent(self.nbPages, forKey: .nbPages)
316+
try container.encodeIfPresent(self.hitsPerPage, forKey: .hitsPerPage)
325317
try container.encode(self.hits, forKey: .hits)
326318
try container.encode(self.query, forKey: .query)
327319
try container.encode(self.params, forKey: .params)
@@ -359,10 +351,10 @@ public struct SearchResponse<T: Codable>: Codable, JSONEncodable {
359351
self.userData = try container.decodeIfPresent(AnyCodable.self, forKey: .userData)
360352
self.queryID = try container.decodeIfPresent(String.self, forKey: .queryID)
361353
self.automaticInsights = try container.decodeIfPresent(Bool.self, forKey: .automaticInsights)
362-
self.page = try container.decode(Int.self, forKey: .page)
363-
self.nbHits = try container.decode(Int.self, forKey: .nbHits)
364-
self.nbPages = try container.decode(Int.self, forKey: .nbPages)
365-
self.hitsPerPage = try container.decode(Int.self, forKey: .hitsPerPage)
354+
self.page = try container.decodeIfPresent(Int.self, forKey: .page)
355+
self.nbHits = try container.decodeIfPresent(Int.self, forKey: .nbHits)
356+
self.nbPages = try container.decodeIfPresent(Int.self, forKey: .nbPages)
357+
self.hitsPerPage = try container.decodeIfPresent(Int.self, forKey: .hitsPerPage)
366358
self.hits = try container.decode([T].self, forKey: .hits)
367359
self.query = try container.decode(String.self, forKey: .query)
368360
self.params = try container.decode(String.self, forKey: .params)
@@ -472,10 +464,10 @@ extension SearchResponse: Hashable where T: Hashable {
472464
hasher.combine(self.userData?.hashValue)
473465
hasher.combine(self.queryID?.hashValue)
474466
hasher.combine(self.automaticInsights?.hashValue)
475-
hasher.combine(self.page.hashValue)
476-
hasher.combine(self.nbHits.hashValue)
477-
hasher.combine(self.nbPages.hashValue)
478-
hasher.combine(self.hitsPerPage.hashValue)
467+
hasher.combine(self.page?.hashValue)
468+
hasher.combine(self.nbHits?.hashValue)
469+
hasher.combine(self.nbPages?.hashValue)
470+
hasher.combine(self.hitsPerPage?.hashValue)
479471
hasher.combine(self.hits.hashValue)
480472
hasher.combine(self.query.hashValue)
481473
hasher.combine(self.params.hashValue)

0 commit comments

Comments
 (0)