OpenAPI Spec / swagger docs: POST /api/ipam/prefixes/{id}/available-prefixes/ requestBody is incorrect #160

Open
opened 2026-04-05 16:22:29 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @epanter-mw on 3/12/2026

NetBox Edition

NetBox Community

NetBox Version

v4.5.4-Docker-4.0.1

Python Version

3.12

Steps to Reproduce

  • create an example prefix:

    $ curl \
      -H "Content-Type: application/json" \
      -H "Accept: application/json; indent=4" \
      -H "Authorization: $NETBOX_AUTH" \
      -X POST  $NETBOX_URL/api/ipam/prefixes/ \
      --data '[{"prefix": "10.0.0.0/8"}]'
    [
      {
          "id": 4,
    [...]
    
  • Open the swagger API docs for POST /api/ipam/prefixes/{id}/available-prefixes/ (i.e. $NETBOX_URL/api/schema/swagger-ui/#/ipam/ipam_prefixes_available_prefixes_create)

  • below "Request body", click "Schema"

  • Expand the PrefixRequest Schema:

Image
  • try to POST using the schema from the spec

    $ curl \
      -H "Content-Type: application/json" \
      -H "Accept: application/json; indent=4" \
      -H "Authorization: $NETBOX_AUTH" \
      -X POST  $NETBOX_URL/api/ipam/prefixes/4/available-prefixes/ \
      --data '[{"prefix": "10.0.1.0/24"}]'
    [
      {
          "prefix_length": "this field can not be missing"
      }
    ]
    
  • try to POST as documented in https://github.com/netbox-community/netbox/blob/main/docs/release-notes/version-2.3.md#automatic-provisioning-of-next-available-prefixes-1694:

    $ curl \
      -H "Content-Type: application/json" \
      -H "Accept: application/json; indent=4" \
      -H "Authorization: $NETBOX_AUTH" \
      -X POST  $NETBOX_URL/api/ipam/prefixes/4/available-prefixes/ \
      --data '[{"prefix_length": 24}]'
    [
      {
          "id": 5,
          "display": "10.0.0.0/24",
    [...]
    

Expected Behavior

The API spec states that prefix_length is required and prefix is not valid.

Observed Behavior

The API spec states that prefix is required and prefix_length is not valid.

*Originally created by @epanter-mw on 3/12/2026* ### NetBox Edition NetBox Community ### NetBox Version v4.5.4-Docker-4.0.1 ### Python Version 3.12 ### Steps to Reproduce - create an example prefix: ``` $ curl \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ -H "Authorization: $NETBOX_AUTH" \ -X POST $NETBOX_URL/api/ipam/prefixes/ \ --data '[{"prefix": "10.0.0.0/8"}]' [ { "id": 4, [...] ``` - Open the swagger API docs for `POST /api/ipam/prefixes/{id}/available-prefixes/` (i.e. `$NETBOX_URL/api/schema/swagger-ui/#/ipam/ipam_prefixes_available_prefixes_create`) - below "Request body", click "Schema" - Expand the `PrefixRequest` Schema: <img width="731" height="1018" alt="Image" src="https://github.com/user-attachments/assets/7b58e279-da9e-457f-9bbf-e41d290e3f9f" /> - try to POST using the schema from the spec ``` $ curl \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ -H "Authorization: $NETBOX_AUTH" \ -X POST $NETBOX_URL/api/ipam/prefixes/4/available-prefixes/ \ --data '[{"prefix": "10.0.1.0/24"}]' [ { "prefix_length": "this field can not be missing" } ] ``` - try to POST as documented in https://github.com/netbox-community/netbox/blob/main/docs/release-notes/version-2.3.md#automatic-provisioning-of-next-available-prefixes-1694: ``` $ curl \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ -H "Authorization: $NETBOX_AUTH" \ -X POST $NETBOX_URL/api/ipam/prefixes/4/available-prefixes/ \ --data '[{"prefix_length": 24}]' [ { "id": 5, "display": "10.0.0.0/24", [...] ``` ### Expected Behavior The API spec states that `prefix_length` is required and `prefix` is not valid. ### Observed Behavior The API spec states that `prefix` is required and `prefix_length` is not valid.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#160