octokit/octokit.net — pull request #606 by mge (2014-11-18 08:03:02+00:00)
Title: Fix an issue where Repository on the Git Reference for a Pull Request was always null.

While using Octokit, I noticed a bug when interacting with Pull Requests. The Repository property for the Head and Base references was always returning null, instead of a valid Repository.

The problem was that the JSON API uses "repo" as the field name, but the object model was expecting "Repository".

The issue here seemed similar to what was fixed by @Haacked for #387, but instead of adding another special case to the name mapping, I updated the serialization logic to allow "[Parameter]" to control the JSON Field name. It looks like this was the intention based on how the GitReference object was designed.

The first three commits in the PR are small changes to SimpleJson itself. I would be happy to try to get these changes pushed up stream if you feel this is the correct approach to the problem. I did not do this proactively as I figured there was no reason to spend them time doing so if you'd rather I take a different approach. The final commit are the changes to the Ocotokit codebase to start using [Parameter] as a way to control serialization.

I did not add a specific test for deserializing a Pull Request object. The root cause of the issue is due to an impedance mismatch between the JSON response and the object model we deserialize to, which is already covered by an existing test, for the "_links" behavior. I'm happy to add one specifically for this scenario if you'd prefer.