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

Change HttpResponseBody.json to take Any #393

Merged
merged 2 commits into from
Jun 9, 2019
Merged

Change HttpResponseBody.json to take Any #393

merged 2 commits into from
Jun 9, 2019

Conversation

edwinveger
Copy link

This PR addresses issue #392 . I have added several unit tests for this behavior.

@edwinveger
Copy link
Author

I only noticed just now that there is a similar PR (#390). However, that PR does not add any tests for the new behavior.

@Mazyod
Copy link
Contributor

Mazyod commented Apr 18, 2019

Thanks for adding the tests.

@Vkt0r
Copy link
Member

Vkt0r commented Apr 20, 2019

Hey, @edwinveger Thanks for taking the time to create this! Can you please update the CHANGELOG.md and I would be happy to merge the PR

@edwinveger
Copy link
Author

@Vkt0r took me a while, but done.

@Vkt0r
Copy link
Member

Vkt0r commented Apr 30, 2019

Hey, @edwinveger thanks! Can you please rebase and clean the branch?

@swifter-bot
Copy link

swifter-bot commented May 2, 2019

1 Message
📖 Hey, @edwinveger 👋.

Generated by 🚫 Danger

@edwinveger
Copy link
Author

@Vkt0r rebase done. By cleaning the branch, do you mean squashing the commits?

Tests are failing to compile on Linux, but I'm not sure how I can fix that.

This is my first open-source PR, thanks for your patience 😁

@Vkt0r
Copy link
Member

Vkt0r commented May 2, 2019

Hey, @edwinveger No problem at all 😉. Don't worry about the Linux tests, I've to report this issue to CircleCI with the Docker image. I'll check out your branch in the meantime and I'll run it locally in my machine with Docker in Linux. Can you please squash your commits ? If everything is running for me locally I'll merge it !

@Vkt0r
Copy link
Member

Vkt0r commented May 6, 2019

@edwinveger I checked your PR locally and it's failing with some tests and also I rerun the failed jobs in CircleCI as they have issues as I mentioned before and now the failed jobs reflect the failed tests see details in the PR, please.

@Vkt0r Vkt0r self-requested a review May 13, 2019 19:43
@Vkt0r
Copy link
Member

Vkt0r commented May 13, 2019

Hey, @edwinveger I was checking out your PR and I figured out what was wrong with it in Linux! We have some compilation conditions for platforms in that specific part of the code and it's not necessary anymore:

case .json(let object):
#if os(Linux)
let data = [UInt8]("Not ready for Linux.".utf8)
return (data.count, {
try $0.write(data)
})
#else
guard JSONSerialization.isValidJSONObject(object) else {
throw SerializationError.invalidObject
}
let data = try JSONSerialization.data(withJSONObject: object)
return (data.count, {
try $0.write(data)
})
#endif
case .text(let body):
let data = [UInt8](body.utf8)
return (data.count, {
try $0.write(data)
})

The condition is not longer necessary as we can use JSONSerialization in Linux now. So replacing it with:

case .json(let object):
    guard JSONSerialization.isValidJSONObject(object) else {
        throw SerializationError.invalidObject
    }
    let data = try JSONSerialization.data(withJSONObject: object)
    return (data.count, {
        try $0.write(data)
    })

Would make your tests pass on macOS and Linux 😄. Can you please update your PR to reflect this change ?

@edwinveger
Copy link
Author

edwinveger commented May 13, 2019 via email

Edwin and others added 2 commits May 29, 2019 14:13
Update changelog
Include the new tests added to the `XCTManifests.swift`
Copy link
Member

@Vkt0r Vkt0r left a comment

Choose a reason for hiding this comment

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

This looks good! Thanks for your contribution @edwinveger.

@Vkt0r Vkt0r merged commit 38470f0 into httpswift:stable Jun 9, 2019
tomieq pushed a commit to tomieq/swifterfork that referenced this pull request Apr 1, 2021
…y-json-dictionary-literals

Change HttpResponseBody.json to take Any
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.

4 participants