Normalize CallToolResult.StructuredContent to JsonElement? (#1357)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
a2ee0c805a
commit
0a0a575a3d
1 changed files with 25 additions and 21 deletions
|
|
@ -654,11 +654,11 @@ public partial class McpServerToolTests
|
|||
}
|
||||
}
|
||||
|
||||
private static void AssertMatchesJsonSchema(JsonElement schemaDoc, JsonNode? value)
|
||||
private static void AssertMatchesJsonSchema(JsonElement schemaDoc, JsonElement? value)
|
||||
{
|
||||
JsonSchema schema = JsonSerializer.Deserialize(schemaDoc, JsonContext2.Default.JsonSchema)!;
|
||||
EvaluationOptions options = new() { OutputFormat = OutputFormat.List };
|
||||
EvaluationResults results = schema.Evaluate(JsonSerializer.SerializeToElement(value, JsonContext2.Default.JsonNode), options);
|
||||
EvaluationResults results = schema.Evaluate(value!.Value, options);
|
||||
if (!results.IsValid)
|
||||
{
|
||||
IEnumerable<string> errors = (results.Details ?? [])
|
||||
|
|
@ -670,7 +670,7 @@ public partial class McpServerToolTests
|
|||
Schema:
|
||||
{JsonSerializer.Serialize(schema)}
|
||||
Instance:
|
||||
{value?.ToJsonString() ?? "null"}
|
||||
{value?.ToString() ?? "null"}
|
||||
Errors:
|
||||
{string.Join(Environment.NewLine, errors)}
|
||||
""");
|
||||
|
|
|
|||
Loading…
Reference in a new issue