Skip to content

[swift5] Fix missing case for FormDataEncoding#encode #11064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

denizdogan
Copy link
Contributor

Fixes #11062

@4brunu

@4brunu
Copy link
Contributor

4brunu commented Dec 7, 2021

Looks good to me 👍

@4brunu
Copy link
Contributor

4brunu commented Dec 8, 2021

@denizdogan could you please also fix the Alamofire implementation please?

let upload = manager.upload(multipartFormData: { mpForm in
for (k, v) in self.parameters! {
switch v {
case let fileURL as URL:
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
} else {
mpForm.append(fileURL, withName: k)
}
case let string as String:
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
case let number as NSNumber:
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
default:
fatalError("Unprocessable value \(v) with key \(k)")
}
}
}, to: URLString, method: xMethod, headers: nil)

It should be a new case like this? (I didn't compile it, so I'm not sure if the syntax is correct)

                         case let data as Data: 
                             mpForm.append(data, withName: k) 

@denizdogan
Copy link
Contributor Author

denizdogan commented Dec 8, 2021

@4brunu Nice catch. I don't speak Alamofire, so thanks for that! Fixed

@wing328 wing328 added this to the 5.3.1 milestone Dec 10, 2021
@wing328 wing328 merged commit c94d2b2 into OpenAPITools:master Dec 10, 2021
@denizdogan denizdogan deleted the fix-form-data branch December 10, 2021 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [swift5] mapFileBinaryToData crashes fatally in URLSessionImplementations.swift
3 participants