Skip to content

Commit

Permalink
fix(hand edit): serialize enrichment parameter
Browse files Browse the repository at this point in the history
based on the generated output, this would write the swift struct literal to the form data. this
change serializes the struct into json before appending.
  • Loading branch information
jeff-arn authored and apaparazzi0329 committed Aug 20, 2020
1 parent 722e3de commit f8e3c28
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Source/DiscoveryV2/Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Discovery {
*/
public init(version: String) throws {
self.version = version

let authenticator = try ConfigBasedAuthenticatorFactory.getAuthenticator(credentialPrefix: serviceSdkName)
self.authenticator = authenticator

Expand Down Expand Up @@ -1539,8 +1539,15 @@ public class Discovery {
multipartFormData.append(enrichmentData, withName: "enrichment")
}
if let file = file {
multipartFormData.append(file, withName: "file", fileName: "filename")
multipartFormData.append(file, withName: "file", mimeType: "application/octet-stream", fileName: "filename")
}

guard let enrichmentJSON = try? JSON.encoder.encode(enrichment) else {
completionHandler(nil, WatsonError.serialization(values: "request body"))
return
}
multipartFormData.append(enrichmentJSON, withName: "enrichment")

guard let body = try? multipartFormData.toData() else {
completionHandler(nil, WatsonError.serialization(values: "request multipart form data"))
return
Expand Down

0 comments on commit f8e3c28

Please sign in to comment.