Fix _meta properties to use JsonObject (#1341)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
parent
c2aa6a5123
commit
d429b0bf64
2 changed files with 5 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Text.Json;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace ModelContextProtocol.Protocol;
|
namespace ModelContextProtocol.Protocol;
|
||||||
|
|
@ -35,5 +35,5 @@ public sealed class Root
|
||||||
/// This is reserved by the protocol for future use.
|
/// This is reserved by the protocol for future use.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[JsonPropertyName("_meta")]
|
[JsonPropertyName("_meta")]
|
||||||
public JsonElement? Meta { get; set; }
|
public JsonObject? Meta { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using ModelContextProtocol.Protocol;
|
using ModelContextProtocol.Protocol;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
namespace ModelContextProtocol.Tests.Protocol;
|
namespace ModelContextProtocol.Tests.Protocol;
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ public static class RootTests
|
||||||
{
|
{
|
||||||
Uri = "file:///home/user/project",
|
Uri = "file:///home/user/project",
|
||||||
Name = "My Project",
|
Name = "My Project",
|
||||||
Meta = JsonDocument.Parse("""{"custom":"data"}""").RootElement.Clone()
|
Meta = new JsonObject { ["custom"] = "data" }
|
||||||
};
|
};
|
||||||
|
|
||||||
string json = JsonSerializer.Serialize(original, McpJsonUtilities.DefaultOptions);
|
string json = JsonSerializer.Serialize(original, McpJsonUtilities.DefaultOptions);
|
||||||
|
|
@ -22,7 +23,7 @@ public static class RootTests
|
||||||
Assert.Equal("file:///home/user/project", deserialized.Uri);
|
Assert.Equal("file:///home/user/project", deserialized.Uri);
|
||||||
Assert.Equal("My Project", deserialized.Name);
|
Assert.Equal("My Project", deserialized.Name);
|
||||||
Assert.NotNull(deserialized.Meta);
|
Assert.NotNull(deserialized.Meta);
|
||||||
Assert.Equal("data", deserialized.Meta.Value.GetProperty("custom").GetString());
|
Assert.Equal("data", (string?)deserialized.Meta["custom"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue