| 289 | // Schema Methods |
| 290 | |
| 291 | fl::vector<Remote::MethodInfo> Remote::methods() const { |
| 292 | fl::vector<MethodInfo> result; |
| 293 | |
| 294 | // Get flat JSON schema from underlying RPC |
| 295 | // Format: [["methodName", "returnType", [["param1", "type1"], ...]], ...] |
| 296 | fl::json jsonMethods = mRpc.methods(); |
| 297 | |
| 298 | if (!jsonMethods.is_array()) { |
| 299 | return result; |
| 300 | } |
| 301 | |
| 302 | // Convert each flat method array to MethodInfo struct |
| 303 | for (fl::size i = 0; i < jsonMethods.size(); i++) { |
| 304 | fl::json method = jsonMethods[i]; |
| 305 | |
| 306 | if (!method.is_array() || method.size() < 3) { |
| 307 | continue; // Invalid method format |
| 308 | } |
| 309 | |
| 310 | MethodInfo info; |
| 311 | |
| 312 | // method[0] = method name |
| 313 | info.name = method[0].as_string().value_or(""); |
| 314 | |
| 315 | // method[1] = return type |
| 316 | info.returnType = method[1].as_string().value_or("void"); |
| 317 | |
| 318 | // method[2] = params array: [["param1", "type1"], ["param2", "type2"], ...] |
| 319 | if (method[2].is_array()) { |
| 320 | fl::json params = method[2]; |
| 321 | for (fl::size j = 0; j < params.size(); j++) { |
| 322 | fl::json param = params[j]; |
| 323 | if (param.is_array() && param.size() >= 2) { |
| 324 | ParamInfo paramInfo; |
| 325 | paramInfo.name = param[0].as_string().value_or(""); |
| 326 | paramInfo.type = param[1].as_string().value_or("unknown"); |
| 327 | info.params.push_back(fl::move(paramInfo)); |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Flat schema doesn't include description/tags |
| 333 | info.description = ""; |
| 334 | info.tags.clear(); |
| 335 | |
| 336 | result.push_back(fl::move(info)); |
| 337 | } |
| 338 | |
| 339 | return result; |
| 340 | } |
| 341 | |
| 342 | } // namespace fl |