IpamIPAddressFamilyChoice differs from the spec #8083

Closed
opened 2025-12-29 20:32:09 +01:00 by adam · 0 comments
Owner

Originally created by @hikhvar on GitHub (May 17, 2023).

Originally assigned to: @abhi1693 on GitHub.

NetBox version

v3.5.1

Python version

3.10.6

Steps to Reproduce

  1. Try to fetch an IP address from netbox:
curl -s -X 'GET' -H 'Authorization: Token testtesttesttesttesttesttesttesttesttest' 'http://0.0.0.0:8080/api/ipam/ip-addresses/' | jq '.results[0].family'
{
  "value": 4,
  "label": "IPv4"
}
  1. Download the OpenAPI spec
    (e.g. using a local netbox-docker installation)
curl -L http://0.0.0.0:8080/api/schema/ -o openapi.yaml
  1. Compare the OpenAPI spec with the given result:
 bin/yq '.components.schemas.IPAddress.properties.family' openapi.yaml
type: object
properties:
  value:
    type: string
  label:
    type: string
readOnly: true

Expected Behavior

The value of the IPAddressFamily type should be either string or a number in both the Spec and the API response.

Observed Behavior

The API returns a number for the IP family, while the Spec says it is a string. The spec should be consistent with the actual response. Generated client in e.g. Golang don't do an automatic type conversion, but will complain about mismatching types.

Current Workaround

Run the following before generating your code:

bin/yq -i '.components.schemas.IPAddress.properties.family.properties.value.type = "integer" ' openapi.yaml
Originally created by @hikhvar on GitHub (May 17, 2023). Originally assigned to: @abhi1693 on GitHub. ### NetBox version v3.5.1 ### Python version 3.10.6 ### Steps to Reproduce 1. Try to fetch an IP address from netbox: ``` curl -s -X 'GET' -H 'Authorization: Token testtesttesttesttesttesttesttesttesttest' 'http://0.0.0.0:8080/api/ipam/ip-addresses/' | jq '.results[0].family' { "value": 4, "label": "IPv4" } ``` 1. Download the OpenAPI spec (e.g. using a local netbox-docker installation) ``` curl -L http://0.0.0.0:8080/api/schema/ -o openapi.yaml ``` 1. Compare the OpenAPI spec with the given result: ``` bin/yq '.components.schemas.IPAddress.properties.family' openapi.yaml type: object properties: value: type: string label: type: string readOnly: true ``` ### Expected Behavior The value of the IPAddressFamily type should be either string or a number in both the Spec and the API response. ### Observed Behavior The API returns a number for the IP family, while the Spec says it is a string. The spec should be consistent with the actual response. Generated client in e.g. Golang don't do an automatic type conversion, but will complain about mismatching types. #### Current Workaround Run the following before generating your code: ``` bin/yq -i '.components.schemas.IPAddress.properties.family.properties.value.type = "integer" ' openapi.yaml ```
adam added the type: bugstatus: acceptedseverity: lowtopic: OpenAPI labels 2025-12-29 20:32:09 +01:00
adam closed this issue 2025-12-29 20:32:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8083