tikoci / restraml

RouterOS REST API "Schema Tools"
https://tikoci.github.io/restraml/
The Unlicense
12 stars 0 forks source link

`inspect.json` should include `request=completion` for arg types #10

Open mobileskyfi opened 3 months ago

mobileskyfi commented 3 months ago

I forgot I never did this in the original generation code. But there is another possible level to "inspect" — command completion. This comes up in the "diff" tool since sometimes it the options for an argument that change, and today that's not viable in the diff.

For example, ":convert from=" - the from has value like "base64", etc, but "byte-array" is new in 7.15 (I think but diff tool don't tell me that)

/console/inspect request=completion path=convert,from
TYPE        COMPLETION  STYLE        OFFSET  PREFERENCE  SHOW  TEXT                         
completion  [           syntax-meta       0  75          no    start of command substitution
completion  (           syntax-meta       0  75          no    start of expression          
completion  $           syntax-meta       0  75          no    substitution                 
completion  "           syntax-meta       0  75          no    start of quoted string       
completion  base32      none              0  96          yes                                
completion  base64      none              0  96          yes                                
completion  byte-array  none              0  96          yes                                
completion  hex         none              0  96          yes                                
completion  raw         none              0  96          yes                                
completion  url         none              0  96          yes                                
completion  *           none              0  -1          no    id prefix                

Note

style=none & preference=yes seems to be good clues as there the possible values in a schema. (Now :convert is a bad example from a REST POV).

Today the inspect.json looks like:

"convert": {
    "_type": "cmd",
    "from": { "_type": "arg" },
    "from-scheme": { "_type": "arg", "desc": "see documentation" },
    "to": { "_type": "arg" },
    "to-scheme": { "_type": "arg", "desc": "see documentation" },
    "transform": { "_type": "arg" },
    "transform-scheme": { "_type": "arg", "desc": "see documentation" },
    "value": { "_type": "arg", "desc": "see documentation" }
  }

The idea here be that the from part have some new variables. Perhaps some new subkey like _completion:

{
  "from": {
    "_type": "arg",
    "_completion": {
      "base64": { "style": "none", "preference": 96 },
      "hex": {}
    }
  }
}