It's an easter egg
Except now we can find them
It's not critical for my needs, but I wrote some code to pull out all the "chicks" ( request=child) in the /console/inspect.
It uses recursion with a ROS function to walk the tree of "child" and returns a ROS ::array (& shoves it into a :global variable called "$ast" too). Surprisingly this DOES NOT get ANY stack overflow or memory limits, at least in v7.6. In fact, after walking the tree, even on a little cAP ac, there are 4329 unique "cmd", "args", and "path" branches, with a few leafs each.
:global ast [:toarray ""]
:global mkast do={
:global mkast
:global ast
:local path ""
:if ([:typeof $1] ~ "str|array") do={ :set path $1 }
:local pchild [/console/inspect as-value request=child path=$path]
:foreach k,v in=$pchild do={
:if (($v->"type") = "child") do={
:local astkey ""
:local arrpath [:toarray $path]
:foreach part in=$arrpath do={
:set astkey "$astkey/$part"
}
:set ($ast->$astkey->($v->"name")) $v
:put "Processing: $astkey $($v->"name") $($v->"node-type")"
:local newpath "$($path),$($v->"name")"
# TODO use [/console/inspect as-value request=syntax path=$path]
[$mkast $newpath]
}
}
return $ast
}
# & this call start the recursion
:put [$mkast]
$ast will also contain the schema as an nested array, reflecting the parent/child relationships... so can use like this:
:put ($ast->"/ip/address")
add=.id=*2;name=add;node-type=cmd;type=child;comment=.id=*3;name=comment;node-type
=cmd;type=child;disable=.id=*4;name=disable;node-type=cmd;type=child;edit=.id=*5;n
ame=edit;node-type=cmd;type=child;enable=.id=*6;name=enable;node-type=cmd;type=chi
ld;export=.id=*7;name=export;node-type=cmd;type=child;find=.id=*8;name=find;node-t
ype=cmd;type=child;get=.id=*9;name=get;node-type=cmd;type=child;print=.id=*a;name=
print;node-type=cmd;type=child;remove=.id=*b;name=remove;node-type=cmd;type=child;
reset=.id=*c;name=reset;node-type=cmd;type=child;set=.id=*d;name=set;node-type=cmd
;type=child
Another example, this is one part of the output $ast array above in YAML-ized style output:
/zerotier/edit:
number:
.id: *2
name: number
node-type: arg
type: child
value-name:
.id: *3
name: value-name
node-type: arg
type: child
/zerotier/enable:
numbers:
.id: *2
name: numbers
node-type: arg
type: child
I don't do it here, but adding another call to "/console/inspect request=syntax ..." for each child with same path would get a description (e.g. type of "explanation"). With that you'd have all the info for a REST schema. My thought is
RAML might be easier to generate from ROS script, since it uses "YAML format", not JSON, and YAML is easier to
generate in ROS script. I think the keys from my code are close to the REST POST things, so that be easiest to model into RAML. And I believe some tools can use or convert from the RAML schema format to swagger / OpenAPI.
But /console/inspect does seem to have the info for a REST schema, now converting is still more work.
One note is /console/inspect seems to know about ALL of the packages (e.g. "extra-packages"), even if not installed – so you'll see child entries for calea, iot, etc. even if not available.