byxorna / nycmesh-tool

nycmesh-tool CLI
Apache License 2.0
1 stars 0 forks source link

Fix UISP Device JSON deserialization #1

Closed byxorna closed 2 years ago

byxorna commented 2 years ago

nycmesh-tool uisp devices getDevices would fail, because the uisp_swagger.yaml incorrectly labeled "date-time" fields as "date", causing deserializing Devices to fail at runtime. I had to make some manual tweaks to the uisp_swagger.yaml (captured in diffs in spec/) to make it compile.

Also note that some manual commenting was necessary to make the generated code compile (comment out sfp1/sfp2 fields and validation, and makeClient())

Old Behavior:

$ nycmesh-tool uisp devices getDevices
Using config file: /home/gabe/.nycmesh-tool.yaml
Error: parsing time "2022-01-09T00:13:34.554Z": extra text: "T00:13:34.554Z"
Usage:
  nycmesh-tool uisp devices getDevices [flags]

Flags:
      --authorized       
  -h, --help             help for getDevices
      --role strings     
      --siteId string    
      --type strings     
      --withInterfaces

Global Flags:
      --config string         config file path
      --debug                 output debug logs
      --dry-run               do not send the request to server
  -f, --format string         output format (table or json) (default "json")
      --hostname string       hostname of the service (default "localhost")
      --scheme string         Choose from: [http] (default "http")
      --skip-verify-tls       sets &tls.Config{InsecureSkipVerify: true} in UISP HTTP Client
      --x-auth-token string   User authorization token

2022/01/08 16:14:30 Error: parsing time "2022-01-09T00:13:34.554Z": extra text: "T00:13:34.554Z"

New Behavior:

$ nycmesh-tool uisp devices getDevices | jq length
# looks like 1290 devices deserialized correctly!
1290