|
21 | 21 |
|
22 | 22 | input_schema = tool.to_h[:input_schema] |
23 | 23 | expect(input_schema[:type]).to eq("object") |
24 | | - expect(input_schema[:properties].first[:name]).to eq("test_property") |
25 | | - expect(input_schema[:properties].first[:required]).to eq(true) |
| 24 | + expect(input_schema[:properties]["test_property"][:type]).to eq("string") |
| 25 | + expect(input_schema[:properties]["test_property"][:description]).to eq("A test property") |
26 | 26 | end |
27 | 27 |
|
28 | 28 | it "serializes to camelCase JSON" do |
|
43 | 43 | expect(parsed).to have_key("inputSchema") |
44 | 44 | expect(parsed["inputSchema"]).to have_key("type") |
45 | 45 | expect(parsed["inputSchema"]).to have_key("properties") |
46 | | - expect(parsed["inputSchema"]["properties"].first).to have_key("name") |
47 | | - expect(parsed["inputSchema"]["properties"].first).to have_key("required") |
| 46 | + expect(parsed["inputSchema"]["properties"]["test_property"]).to have_key("type") |
| 47 | + expect(parsed["inputSchema"]["properties"]["test_property"]).to have_key("description") |
48 | 48 | end |
49 | 49 | end |
50 | 50 |
|
|
82 | 82 | tools.add_tool(tool) |
83 | 83 |
|
84 | 84 | # Expected output hash |
85 | | - expected_hash = { |
86 | | - "jsonrpc" => "2.0", |
87 | | - "id" => 1, |
88 | | - "result" => { |
89 | | - "tools" => [ |
| 85 | + expected_hash = JSON.parse <<~JSON |
| 86 | + { |
| 87 | + "jsonrpc": "2.0", |
| 88 | + "id": 1, |
| 89 | + "result": { |
| 90 | + "tools": [ |
90 | 91 | { |
91 | | - "name" => "get_weather", |
92 | | - "description" => "Get current weather information for a location", |
93 | | - "inputSchema" => { |
94 | | - "type" => "object", |
95 | | - "properties" => [ |
96 | | - { |
97 | | - "name" => "location", |
98 | | - "type" => "string", |
99 | | - "description" => "City name or zip code", |
100 | | - "required" => true |
| 92 | + "name": "get_weather", |
| 93 | + "description": "Get current weather information for a location", |
| 94 | + "inputSchema": { |
| 95 | + "type": "object", |
| 96 | + "properties": { |
| 97 | + "location": { |
| 98 | + "type": "string", |
| 99 | + "description": "City name or zip code" |
101 | 100 | } |
102 | | - ] |
| 101 | + }, |
| 102 | + "required": ["location"] |
103 | 103 | } |
104 | 104 | } |
105 | 105 | ], |
106 | | - "nextCursor" => "next-page-cursor" |
| 106 | + "nextCursor": "next-page-cursor" |
107 | 107 | } |
108 | 108 | } |
| 109 | + JSON |
109 | 110 |
|
110 | 111 | json_output = tools.to_json |
111 | 112 | parsed_output = JSON.parse(json_output) |
|
0 commit comments