parent
a88ef0deb7
commit
3156818d66
2 changed files with 24 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
<System9Version>9.0.5</System9Version>
|
||||
<System10Version>10.0.0-preview.4.25258.110</System10Version>
|
||||
<MicrosoftExtensionsAIVersion>9.7.0</MicrosoftExtensionsAIVersion>
|
||||
<MicrosoftExtensionsAIVersion>9.7.1</MicrosoftExtensionsAIVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Product dependencies netstandard -->
|
||||
|
|
|
|||
|
|
@ -563,6 +563,27 @@ public partial class McpServerToolTests
|
|||
Assert.Null(result.StructuredContent);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(JsonNumberHandling.Strict)]
|
||||
[InlineData(JsonNumberHandling.AllowReadingFromString)]
|
||||
public async Task ToolWithNullableParameters_ReturnsExpectedSchema(JsonNumberHandling nunmberHandling)
|
||||
{
|
||||
JsonSerializerOptions options = new(JsonContext2.Default.Options) { NumberHandling = nunmberHandling };
|
||||
McpServerTool tool = McpServerTool.Create((int? x = 42, DateTimeOffset? y = null) => { }, new() { SerializerOptions = options });
|
||||
|
||||
JsonElement expectedSchema = JsonDocument.Parse("""
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": { "type": ["integer", "null"], "default": 42 },
|
||||
"y": { "type": ["string", "null"], "format": "date-time", "default": null }
|
||||
}
|
||||
}
|
||||
""").RootElement;
|
||||
|
||||
Assert.True(JsonElement.DeepEquals(expectedSchema, tool.ProtocolTool.InputSchema));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> StructuredOutput_ReturnsExpectedSchema_Inputs()
|
||||
{
|
||||
yield return new object[] { "string" };
|
||||
|
|
@ -695,5 +716,7 @@ public partial class McpServerToolTests
|
|||
[JsonSerializable(typeof(JsonSchema))]
|
||||
[JsonSerializable(typeof(List<AIContent>))]
|
||||
[JsonSerializable(typeof(List<string>))]
|
||||
[JsonSerializable(typeof(int?))]
|
||||
[JsonSerializable(typeof(DateTimeOffset?))]
|
||||
partial class JsonContext2 : JsonSerializerContext;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue