@@ -9,11 +9,11 @@ import Foundation
99public struct MultipleBatchRequest : Codable , JSONEncodable {
1010 public var action : SearchAction
1111 /// Operation arguments (varies with specified `action`).
12- public var body : AnyCodable
12+ public var body : AnyCodable ?
1313 /// Index name (case-sensitive).
1414 public var indexName : String
1515
16- public init ( action: SearchAction , body: AnyCodable , indexName: String ) {
16+ public init ( action: SearchAction , body: AnyCodable ? = nil , indexName: String ) {
1717 self . action = action
1818 self . body = body
1919 self . indexName = indexName
@@ -30,7 +30,7 @@ public struct MultipleBatchRequest: Codable, JSONEncodable {
3030 public func encode( to encoder: Encoder ) throws {
3131 var container = encoder. container ( keyedBy: CodingKeys . self)
3232 try container. encode ( self . action, forKey: . action)
33- try container. encode ( self . body, forKey: . body)
33+ try container. encodeIfPresent ( self . body, forKey: . body)
3434 try container. encode ( self . indexName, forKey: . indexName)
3535 }
3636}
@@ -46,7 +46,7 @@ extension MultipleBatchRequest: Equatable {
4646extension MultipleBatchRequest : Hashable {
4747 public func hash( into hasher: inout Hasher ) {
4848 hasher. combine ( self . action. hashValue)
49- hasher. combine ( self . body. hashValue)
49+ hasher. combine ( self . body? . hashValue)
5050 hasher. combine ( self . indexName. hashValue)
5151 }
5252}
0 commit comments