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

Closed
opened 2025-12-29 18:30:31 +01:00 by adam · 2 comments
Owner

Originally created by @miticotoby on GitHub (May 11, 2020).

Environment

  • Python version: docker python:3.7-alpine
  • NetBox version: 2.7.12

Steps to Reproduce

  • first off I was asked by the kind folks at netbox-community/go-netbox to open this issue here since swagger.json is generated dynamically
  • there are a couple of type issues in the swagger scheme which causes type issues on languages like golang
  • I'm not fluent in python, and some of these issues are a bit over my head. otherwise I'd be happy to open a PR
  • simple API calls to reproduce will suffice
  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

Originally created by @miticotoby on GitHub (May 11, 2020). ### Environment * Python version: docker python:3.7-alpine * NetBox version: 2.7.12 ### Steps to Reproduce - first off I was asked by the kind folks at netbox-community/go-netbox to open this issue here since swagger.json is generated dynamically - there are a couple of type issues in the swagger scheme which causes type issues on languages like golang - I'm not fluent in python, and some of these issues are a bit over my head. otherwise I'd be happy to open a PR - simple API calls to reproduce will suffice 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", ``` 2. 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
adam closed this issue 2025-12-29 18:30:31 +01:00
Author
Owner

@glennmatthews commented on GitHub (May 11, 2020):

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

@glennmatthews commented on GitHub (May 11, 2020): `count_ipaddresses` was previously reported as #4395 and should already be fixed in 2.7.12 by #4467.
Author
Owner

@jeremystretch commented on GitHub (May 20, 2020):

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.

@jeremystretch commented on GitHub (May 20, 2020): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3670