mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 19:26:51 +00:00
Change Payload to a Dictionary<string, string> (#2303)
When serializing the `NewDeployment` type, the `Payload` is serialized as an escaped string because JSON.NET doesn't know it's meant to be JSON. This causes a problem when you call the API because the Payload is supposed to be a JSON dictionary that's just part of the overall payload. It's not supposed to be an escaped string. That's why the JSON deserializer fails on it. Not only that, any deployments created using the current Octokit.net will create an invalid payload. This PR fixes it by changing the type of `Payload` to a dictionary. THIS IS A BREAKING CHANGE, but the old behavior was broken so it forces a new correct behavior. Fixes #2250
This commit is contained in:
@@ -8,6 +8,18 @@ namespace Octokit.Tests.Models
|
||||
{
|
||||
public class DeploymentTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanSerialize()
|
||||
{
|
||||
var deployment = new NewDeployment("ref")
|
||||
{
|
||||
Payload = new Dictionary<string, string> {{"environment", "production"}}
|
||||
};
|
||||
var deserialized = new SimpleJsonSerializer().Serialize(deployment);
|
||||
|
||||
Assert.Equal(@"{""ref"":""ref"",""task"":""deploy"",""payload"":{""environment"":""production""}}", deserialized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanDeserialize()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
@@ -59,7 +60,7 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// JSON payload with extra information about the deployment.
|
||||
/// </summary>
|
||||
public string Payload { get; set; }
|
||||
public Dictionary<string, string> Payload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional name for the target deployment environment (e.g., production, staging, qa). Default: "production"
|
||||
|
||||
Reference in New Issue
Block a user