Skip to content
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

Update Alamofire #273

Merged
merged 6 commits into from
Aug 5, 2021
Merged

Update Alamofire #273

merged 6 commits into from
Aug 5, 2021

Conversation

0x0c
Copy link
Contributor

@0x0c 0x0c commented May 24, 2021

Hi, I updated Alamofire 4.9.0 to 5.4.3 (latest version) and also update templates to confirm Alamofire's API changes.
I checked all tests are passed and a generated client can send request.

@0x0c
Copy link
Contributor Author

0x0c commented Jun 27, 2021

@yonaskolb Is there any suggestions to merge this PR? I'm welcome any revise request :)

encodingCompletion: { result in
switch result {
case .success(let uploadRequest, _, _):
cancellableRequest.networkRequest = uploadRequest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all this still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yonaskolb Thank you for your comment! Sorry, I'm not sure your comment so could you describe more detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yonaskolb Oh, I got it. I have to add responseData method to handle response.
I will revise this code to as follows. Did I get that right?

cancellableRequest.networkRequest = sessionManager.upload(
    multipartFormData: { multipartFormData in
        for (name, value) in request.formParameters {
            if let file = value as? UploadFile {
                switch file.type {
                case let .url(url):
                    if let fileName = file.fileName, let mimeType = file.mimeType {
                        multipartFormData.append(url, withName: name, fileName: fileName, mimeType: mimeType)
                    } else {
                        multipartFormData.append(url, withName: name)
                    }
                case let .data(data):
                    if let fileName = file.fileName, let mimeType = file.mimeType {
                        multipartFormData.append(data, withName: name, fileName: fileName, mimeType: mimeType)
                    } else {
                        multipartFormData.append(data, withName: name)
                    }
                }
            } else if let url = value as? URL {
                multipartFormData.append(url, withName: name)
            } else if let data = value as? Data {
                multipartFormData.append(data, withName: name)
            } else if let string = value as? String {
                multipartFormData.append(Data(string.utf8), withName: name)
            }
        }
    },
    with: urlRequest
).responseData(queue: decodingQueue) { dataResponse in
    self.handleResponse(request: request, requestBehaviour: requestBehaviour, dataResponse: dataResponse, completionQueue: completionQueue, complete: complete)
}

@b00tsy
Copy link

b00tsy commented Jul 14, 2021

Thanks for preparing the PR, any news on the PR review?

@0x0c
Copy link
Contributor Author

0x0c commented Jul 14, 2021

@b00tsy I'm waiting comments from @yonaskolb :)

@yonaskolb
Copy link
Owner

Sorry for the delay @0x0c! I got your great work over the line for you!

@yonaskolb yonaskolb merged commit 1f3f745 into yonaskolb:master Aug 5, 2021
@0x0c
Copy link
Contributor Author

0x0c commented Aug 5, 2021

@yonaskolb Thanks a lot!

kerrmarin-lvmh pushed a commit to kerrmarin-lvmh/SwagGen that referenced this pull request Sep 28, 2021
* Update Alamofire

* Store upload request.

* Update build_spec.sh

* commit diffs

* update changelog

* handle upload response

Co-authored-by: yonaskolb <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants