@@ -9,11 +9,11 @@ import Foundation
9
9
public struct MultipleBatchRequest : Codable , JSONEncodable {
10
10
public var action : SearchAction
11
11
/// Operation arguments (varies with specified `action`).
12
- public var body : AnyCodable
12
+ public var body : AnyCodable ?
13
13
/// Index name (case-sensitive).
14
14
public var indexName : String
15
15
16
- public init ( action: SearchAction , body: AnyCodable , indexName: String ) {
16
+ public init ( action: SearchAction , body: AnyCodable ? = nil , indexName: String ) {
17
17
self . action = action
18
18
self . body = body
19
19
self . indexName = indexName
@@ -30,7 +30,7 @@ public struct MultipleBatchRequest: Codable, JSONEncodable {
30
30
public func encode( to encoder: Encoder ) throws {
31
31
var container = encoder. container ( keyedBy: CodingKeys . self)
32
32
try container. encode ( self . action, forKey: . action)
33
- try container. encode ( self . body, forKey: . body)
33
+ try container. encodeIfPresent ( self . body, forKey: . body)
34
34
try container. encode ( self . indexName, forKey: . indexName)
35
35
}
36
36
}
@@ -46,7 +46,7 @@ extension MultipleBatchRequest: Equatable {
46
46
extension MultipleBatchRequest : Hashable {
47
47
public func hash( into hasher: inout Hasher ) {
48
48
hasher. combine ( self . action. hashValue)
49
- hasher. combine ( self . body. hashValue)
49
+ hasher. combine ( self . body? . hashValue)
50
50
hasher. combine ( self . indexName. hashValue)
51
51
}
52
52
}
0 commit comments