netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.44k stars 2.52k forks source link

swagger/api type issues for /api/dcim/interfaces route #4620

Closed miticotoby closed 4 years ago

miticotoby commented 4 years ago

Environment

Steps to Reproduce

  1. interface property "mgmt_only" is described as string, correct type would be bool
    curl -s -H "Authorization: Token ${NETBOX_HASH}" -H "Content-Type: application/json" "https://${NETBOX_HOST}/api/dcim/interfaces/" | jq '.results[] | .mgmt_only'

    returns: true vs "true"

patch for swagger.json:

--- go-netbox/swagger.json  2020-05-11 14:14:16.974328889 +0200
+++ fixed/swagger.json    2020-05-07 16:38:52.530348124 +0200
@@ -5067,7 +5067,7 @@
             "in": "query",
             "description": "",
             "required": false,
-            "type": "string"
+            "type": "boolean"
           },
           {
             "name": "mode",
  1. interface property "count_ipaddresses" is described as string, correct type would be integer
    curl -s -H "Authorization: Token ${NETBOX_HASH}" -H "Content-Type: application/json" "https://${NETBOX_HOST}/api/dcim/interfaces/" | jq '.results[] | .count_ipaddresses'

    returns: 1 vs "1"

patch for swagger.json:

--- go-netbox/swagger.json  2020-05-11 14:14:16.974328889 +0200
+++ fixed/swagger.json    2020-05-07 16:38:52.530348124 +0200
@@ -20450,7 +20461,7 @@
         },
         "count_ipaddresses": {
           "title": "Count ipaddresses",
-          "type": "string",
+          "type": "integer",
           "readOnly": true
         }
       }

Expected Behavior

swagger compiled client library able to unmarshal interface as expected

Observed Behavior

unmarshal type panic/exception when reading interface over API

glennmatthews commented 4 years ago

count_ipaddresses was previously reported as #4395 and should already be fixed in 2.7.12 by #4467.

jeremystretch commented 4 years ago

I'm closing this issue as it pertains to an outdated NetBox release, and because it identifies multiple discrete issues. Please open individual bug reports for any issues that are still applicable on the current stable release.