Swagger spec for available-prefixes are incorrect #3986

Closed
opened 2025-12-29 18:32:28 +01:00 by adam · 1 comment
Owner

Originally created by @joakimhellum on GitHub (Aug 14, 2020).

Originally assigned to: @joakimhellum on GitHub.

Environment

  • Python version: N/A
  • NetBox version: 103a0e2b32d1 (v2.8.9)

Steps to Reproduce

The swagger spec states that POST /ipam/prefixes/{id}/available-prefixes/ returns list of AvailablePrefix objects, but it seems to actually return list of Prefix objects or single Prefix object depending on what is requested.

Expected Behavior

Expected the following command to return list of AvailablePrefix objects:

curl -X POST "https://localhost:8000/api/ipam/prefixes/<prefix-id>/available-prefixes/" -H "Authorization: Token <token>" -H "Content-Type: application/json" -d "{ \"prefix_length\": 24}"

Observed Behavior

But instead returned what looks like a single Prefix object:

{"id":169,"family":{"value":4,"label":"IPv4"},"prefix":"10.0.1.0/24","site":null,"vrf":null,"tenant":null,"vlan":null,"status":{"value":"active","label":"Active","id":1},"role":null,"is_pool":false,"description":"","tags":[],"custom_fields":{},"created":"2020-08-14","last_updated":"2020-08-14T12:27:01.701782Z"}

Reference to:
https://github.com/netbox-community/netbox/blob/v2.8.9/netbox/ipam/api/views.py#L83

Happy to create pull create to fix this.

Originally created by @joakimhellum on GitHub (Aug 14, 2020). Originally assigned to: @joakimhellum on GitHub. <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: N/A * NetBox version: 103a0e2b32d1 (v2.8.9) <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce The swagger spec states that POST `/ipam/prefixes/{id}/available-prefixes/` returns list of `AvailablePrefix` objects, but it seems to actually return list of `Prefix` objects or single `Prefix` object depending on what is requested. <!-- What did you expect to happen? --> ### Expected Behavior Expected the following command to return list of `AvailablePrefix` objects: ``` curl -X POST "https://localhost:8000/api/ipam/prefixes/<prefix-id>/available-prefixes/" -H "Authorization: Token <token>" -H "Content-Type: application/json" -d "{ \"prefix_length\": 24}" ``` <!-- What happened instead? --> ### Observed Behavior But instead returned what looks like a single `Prefix` object: ``` {"id":169,"family":{"value":4,"label":"IPv4"},"prefix":"10.0.1.0/24","site":null,"vrf":null,"tenant":null,"vlan":null,"status":{"value":"active","label":"Active","id":1},"role":null,"is_pool":false,"description":"","tags":[],"custom_fields":{},"created":"2020-08-14","last_updated":"2020-08-14T12:27:01.701782Z"} ``` Reference to: https://github.com/netbox-community/netbox/blob/v2.8.9/netbox/ipam/api/views.py#L83 Happy to create pull create to fix this.
adam added the type: bugstatus: accepted labels 2025-12-29 18:32:28 +01:00
adam closed this issue 2025-12-29 18:32:28 +01:00
Author
Owner

@lampwins commented on GitHub (Aug 17, 2020):

The Prefix serializer is the correct response, so we would want to adjust the spec as such.

@lampwins commented on GitHub (Aug 17, 2020): The Prefix serializer is the correct response, so we would want to adjust the spec as such.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3986