Skip to content

Commit a84bba0

Browse files
algolia-botkai687
andcommitted
fix(specs): body is not required in multiple batch request (generated)
algolia/api-clients-automation#3454 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Kai Welke <[email protected]>
1 parent 429fa99 commit a84bba0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/Search/Models/MultipleBatchRequest.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import Foundation
99
public 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 {
4646
extension 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

Comments
 (0)