go.mod: upgrade to jsonschema v0.4.2 (#732)
Visible changes:
- Inference on structs populates PropertyOrder
- An empty map for Schema.Properties marshals as "{}"
This commit is contained in:
parent
27b3354f80
commit
9c4d349ec0
3 changed files with 58 additions and 31 deletions
|
|
@ -812,10 +812,34 @@ func TestToolForSchemas(t *testing.T) {
|
|||
|
||||
var (
|
||||
falseSchema = &schema{Not: &schema{}}
|
||||
inSchema = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"p": {Type: "integer"}}}
|
||||
inSchema2 = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"p": {Type: "string"}}}
|
||||
outSchema = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"b": {Type: "boolean"}}}
|
||||
outSchema2 = &schema{Type: "object", AdditionalProperties: falseSchema, Properties: map[string]*schema{"b": {Type: "integer"}}}
|
||||
inSchema = &schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
Properties: map[string]*schema{"p": {Type: "integer"}},
|
||||
PropertyOrder: []string{"p"},
|
||||
}
|
||||
inSchema2 = &schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
Properties: map[string]*schema{"p": {Type: "string"}},
|
||||
}
|
||||
inSchema3 = &schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
Properties: map[string]*schema{}, // empty map is preserved
|
||||
}
|
||||
outSchema = &schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
Properties: map[string]*schema{"b": {Type: "boolean"}},
|
||||
PropertyOrder: []string{"b"},
|
||||
}
|
||||
outSchema2 = &schema{
|
||||
Type: "object",
|
||||
AdditionalProperties: falseSchema,
|
||||
Properties: map[string]*schema{"b": {Type: "integer"}},
|
||||
PropertyOrder: []string{"b"},
|
||||
}
|
||||
)
|
||||
|
||||
// Infer both schemas.
|
||||
|
|
@ -829,6 +853,8 @@ func TestToolForSchemas(t *testing.T) {
|
|||
testToolForSchema[in, any](t, &Tool{}, `{"p":"x"}`, 0, inSchema, nil, `want "integer"`)
|
||||
// Tool sets input schema: that is what's used.
|
||||
testToolForSchema[in, any](t, &Tool{InputSchema: inSchema2}, `{"p":3}`, 0, inSchema2, nil, `want "string"`)
|
||||
// Tool sets input schema, empty properties map.
|
||||
testToolForSchema[in, any](t, &Tool{InputSchema: inSchema3}, `{}`, 0, inSchema3, nil, "")
|
||||
// Tool sets output schema: that is what's used, and validation happens.
|
||||
testToolForSchema[in, any](t, &Tool{OutputSchema: outSchema2}, `{"p":3}`, out{true},
|
||||
inSchema, outSchema2, `want "integer"`)
|
||||
|
|
@ -850,6 +876,7 @@ func TestToolForSchemas(t *testing.T) {
|
|||
"AsOf": {Type: "string"},
|
||||
"Source": {Type: "string"},
|
||||
},
|
||||
PropertyOrder: []string{"Summary", "AsOf", "Source"},
|
||||
},
|
||||
"")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,15 +92,15 @@ infoWithIcon
|
|||
"description": "return resourceLink content with Icon",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"In"
|
||||
],
|
||||
"properties": {
|
||||
"In": {
|
||||
"type": "string",
|
||||
"description": "the input"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"In"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"name": "contentTool",
|
||||
|
|
@ -110,14 +110,14 @@ infoWithIcon
|
|||
"description": "say hi",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Name"
|
||||
],
|
||||
"properties": {
|
||||
"Name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"Name"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"name": "greetWithIcon",
|
||||
|
|
|
|||
36
mcp/testdata/conformance/server/tools.txtar
vendored
36
mcp/testdata/conformance/server/tools.txtar
vendored
|
|
@ -69,14 +69,14 @@ inc
|
|||
"description": "say hi",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Name"
|
||||
],
|
||||
"properties": {
|
||||
"Name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"Name"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"name": "greet"
|
||||
|
|
@ -95,70 +95,70 @@ inc
|
|||
"name": "inc",
|
||||
"outputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"y"
|
||||
],
|
||||
"properties": {
|
||||
"y": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"y"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"In"
|
||||
],
|
||||
"properties": {
|
||||
"In": {
|
||||
"type": "string",
|
||||
"description": "the input"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"In"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"name": "structured",
|
||||
"outputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Out"
|
||||
],
|
||||
"properties": {
|
||||
"Out": {
|
||||
"type": "string",
|
||||
"description": "the output"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"Out"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Now"
|
||||
],
|
||||
"properties": {
|
||||
"Now": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"Now"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"name": "tomorrow",
|
||||
"outputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"Tomorrow"
|
||||
],
|
||||
"properties": {
|
||||
"Tomorrow": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"Tomorrow"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue