mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
Allow [Parameter] to control JSON Field Names.
Previously, SimpleJsonSerializer.MapClrMemberNameToJsonFieldName special cased the name "Links" since while that was the name of the property in the object model, in JSON "_links" was used instead. It turns out that there was an additional problem, where GitReference wants to expose as Repository, but the name in JSON responses is "repo". Instead of simply adding another special case to MapClrMemberNameToJsonFieldName, we update the implementation of the serializer to allow [Parameter(Key = "some_name")] to denote what name we'd like to use for the field in the JSON object when we serialize.
This commit is contained in:
@@ -135,7 +135,7 @@ namespace Octokit.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IgnoresUnderscore()
|
||||
public void RespectsParameterKeyName()
|
||||
{
|
||||
const string json = "{\"_links\":\"blah\"}";
|
||||
|
||||
@@ -151,6 +151,7 @@ namespace Octokit.Tests
|
||||
public string FirstName { get; set; }
|
||||
public bool IsSomething { get; set; }
|
||||
public bool Private { get; set; }
|
||||
[Parameter(Key = "_links")]
|
||||
public string Links { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user