Require Tool inputSchema during deserialization (#1600)
This commit is contained in:
parent
a04c3e4f50
commit
df0c102d75
2 changed files with 9 additions and 0 deletions
|
|
@ -64,6 +64,7 @@ public sealed class Tool : IBaseMetadata
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[JsonPropertyName("inputSchema")]
|
[JsonPropertyName("inputSchema")]
|
||||||
|
[JsonRequired]
|
||||||
public JsonElement InputSchema
|
public JsonElement InputSchema
|
||||||
{
|
{
|
||||||
get => field;
|
get => field;
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,14 @@ public static class ToolTests
|
||||||
Assert.Equal("object", typeElement.GetString());
|
Assert.Equal("object", typeElement.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public static void ToolInputSchema_DeserializationRejectsMissingInputSchema()
|
||||||
|
{
|
||||||
|
const string json = """{"name":"test"}""";
|
||||||
|
|
||||||
|
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<Tool>(json, McpJsonUtilities.DefaultOptions));
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("null")]
|
[InlineData("null")]
|
||||||
[InlineData("false")]
|
[InlineData("false")]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue