swagger/api type issues for /api/ipam/prefixes/X/available-ips/ route #3671

Closed
opened 2025-12-29 18:30:31 +01:00 by adam · 1 comment
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. response type for /api/ipam/prefixes/X/available-ips incorrect. swagger expects type Prefix, while response is actually array of NestedIPAddress

  2. unable to pass "limit" option in GET /api/ipam/prefixes/X/available-ips call when library generated through swagger. api itself seems to implement it. so curl call with limit set works. but the swagger json does not include such option

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
@@ -12899,12 +12899,23 @@
       "get": {
         "operationId": "ipam_prefixes_available-ips_read",
         "description": "A convenience method for returning available IP addresses within a prefix. By default, the number of IPs\nreturned will be equivalent to PAGINATE_COUNT. An arbitrary limit (up to MAX_PAGE_SIZE, if set) may be passed,\nhowever results will not be paginated.\n\nThe advisory lock decorator uses a PostgreSQL advisory lock to prevent this API from being\ninvoked in parallel, which results in a race condition where multiple insertions can occur.",
-        "parameters": [],
+        "parameters": [
+          {
+            "name": "limit",
+            "in": "query",
+            "description": "Number of results to return per page.",
+            "required": false,
+            "type": "integer"
+          }
+        ],
         "responses": {
           "200": {
             "description": "",
             "schema": {
-              "$ref": "#/definitions/Prefix"
+              "type": "array",
+              "items": {
+                "$ref": "#/definitions/NestedIPAddress"
+              }
             }
           }
         },

Expected Behavior

swagger compiled client library able to unmarshal interface as expected
returned list includes all available IPs

Observed Behavior

unmarshal type panic/exception when reading interface over API
returned list includes only first 20 IPs

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. response type for /api/ipam/prefixes/X/available-ips incorrect. swagger expects type Prefix, while response is actually array of NestedIPAddress 2. unable to pass "limit" option in GET /api/ipam/prefixes/X/available-ips call when library generated through swagger. api itself seems to implement it. so curl call with limit set works. but the swagger json does not include such option 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 @@ -12899,12 +12899,23 @@ "get": { "operationId": "ipam_prefixes_available-ips_read", "description": "A convenience method for returning available IP addresses within a prefix. By default, the number of IPs\nreturned will be equivalent to PAGINATE_COUNT. An arbitrary limit (up to MAX_PAGE_SIZE, if set) may be passed,\nhowever results will not be paginated.\n\nThe advisory lock decorator uses a PostgreSQL advisory lock to prevent this API from being\ninvoked in parallel, which results in a race condition where multiple insertions can occur.", - "parameters": [], + "parameters": [ + { + "name": "limit", + "in": "query", + "description": "Number of results to return per page.", + "required": false, + "type": "integer" + } + ], "responses": { "200": { "description": "", "schema": { - "$ref": "#/definitions/Prefix" + "type": "array", + "items": { + "$ref": "#/definitions/NestedIPAddress" + } } } }, ``` ### Expected Behavior swagger compiled client library able to unmarshal interface as expected returned list includes all available IPs ### Observed Behavior unmarshal type panic/exception when reading interface over API returned list includes only first 20 IPs
adam added the status: duplicate label 2025-12-29 18:30:31 +01:00
adam closed this issue 2025-12-29 18:30:31 +01:00
Author
Owner

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

Please limit each issue you open to a specific point to ensure they can be worked on efficiently. Item 1 was addressed in #3356. Item 2 needs a proper bug report including the steps that can be taken to reproduce the observed issue. Please open a new issue for it to prevent conflation with the duplicated report.

@jeremystretch commented on GitHub (May 11, 2020): Please limit each issue you open to a specific point to ensure they can be worked on efficiently. Item 1 was addressed in #3356. Item 2 needs a proper bug report including the steps that can be taken to reproduce the observed issue. Please open a new issue for it to prevent conflation with the duplicated report.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3671