Skip to content

Commit baec768

Browse files
algolia-botben-kalmusClaraMuller
committed
feat(specs): add compositions deduplication setting (generated)
algolia/api-clients-automation#5418 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Ben Kalmus <[email protected]> Co-authored-by: Clara Muller <[email protected]>
1 parent 5dd392f commit baec768

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
/// Deduplication positioning configures how a duplicate result should be resolved between an injected item and main
10+
/// search results. Current configuration supports: - 'highest': always select the item in the highest position, and
11+
/// remove duplicates that appear lower in the results. - 'highestInjected': duplicate result will be moved to its
12+
/// highest possible injected position, but not higher. If a duplicate appears higher in main search results, it will
13+
/// be removed to stay it's intended group position (which could be lower than main).
14+
public enum DedupPositioning: String, Codable, CaseIterable {
15+
case highest
16+
case highestInjected
17+
}
18+
19+
extension DedupPositioning: Hashable {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
/// Deduplication configures the methods used to resolve duplicate items between main search results and injected group
10+
/// results.
11+
public struct Deduplication: Codable, JSONEncodable {
12+
public var positioning: DedupPositioning
13+
14+
public init(positioning: DedupPositioning) {
15+
self.positioning = positioning
16+
}
17+
18+
public enum CodingKeys: String, CodingKey, CaseIterable {
19+
case positioning
20+
}
21+
22+
// Encodable protocol methods
23+
24+
public func encode(to encoder: Encoder) throws {
25+
var container = encoder.container(keyedBy: CodingKeys.self)
26+
try container.encode(self.positioning, forKey: .positioning)
27+
}
28+
}
29+
30+
extension Deduplication: Equatable {
31+
public static func ==(lhs: Deduplication, rhs: Deduplication) -> Bool {
32+
lhs.positioning == rhs.positioning
33+
}
34+
}
35+
36+
extension Deduplication: Hashable {
37+
public func hash(into hasher: inout Hasher) {
38+
hasher.combine(self.positioning.hashValue)
39+
}
40+
}

Sources/Composition/Models/Injection.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ public struct Injection: Codable, JSONEncodable {
1010
public var main: CompositionMain
1111
/// list of injected items of the current Composition.
1212
public var injectedItems: [InjectedItem]?
13+
public var deduplication: Deduplication?
1314

14-
public init(main: CompositionMain, injectedItems: [InjectedItem]? = nil) {
15+
public init(main: CompositionMain, injectedItems: [InjectedItem]? = nil, deduplication: Deduplication? = nil) {
1516
self.main = main
1617
self.injectedItems = injectedItems
18+
self.deduplication = deduplication
1719
}
1820

1921
public enum CodingKeys: String, CodingKey, CaseIterable {
2022
case main
2123
case injectedItems
24+
case deduplication
2225
}
2326

2427
// Encodable protocol methods
@@ -27,19 +30,22 @@ public struct Injection: Codable, JSONEncodable {
2730
var container = encoder.container(keyedBy: CodingKeys.self)
2831
try container.encode(self.main, forKey: .main)
2932
try container.encodeIfPresent(self.injectedItems, forKey: .injectedItems)
33+
try container.encodeIfPresent(self.deduplication, forKey: .deduplication)
3034
}
3135
}
3236

3337
extension Injection: Equatable {
3438
public static func ==(lhs: Injection, rhs: Injection) -> Bool {
3539
lhs.main == rhs.main &&
36-
lhs.injectedItems == rhs.injectedItems
40+
lhs.injectedItems == rhs.injectedItems &&
41+
lhs.deduplication == rhs.deduplication
3742
}
3843
}
3944

4045
extension Injection: Hashable {
4146
public func hash(into hasher: inout Hasher) {
4247
hasher.combine(self.main.hashValue)
4348
hasher.combine(self.injectedItems?.hashValue)
49+
hasher.combine(self.deduplication?.hashValue)
4450
}
4551
}

0 commit comments

Comments
 (0)