OpenAPI generated model for IPAddress.assigned_object fails validation against webhook body #6935

Closed
opened 2025-12-29 19:46:58 +01:00 by adam · 2 comments
Owner

Originally created by @jeremypng on GitHub (Sep 5, 2022).

NetBox version

v3.3.1

Python version

3.8

Steps to Reproduce

  1. Generate pydantic class from openapi spec, attach to FastAPI server
  2. Configure webhook to fire on changed IPAddress object
  3. FastAPI responds w/ 422 unprocessable entity

Received JSON from Netbox for data.assigned_object looks like this:

{
    'id'= 4,
    'url'= '/api/dcim/interfaces/4/',
    'display'= 'Loopback0',
    'device'= {
        'id'= 4,
        'url'= '/api/dcim/devices/4/',
        'display'= 'pez_simulator',
        'name'= 'pez_simulator'
    },
    'name'= 'Loopback0',
    'cable'= None,
    '_occupied'= False
}

The openapi definition from the apidocs endpoint specifies that each property in the dict for assigned_object be a string. But the device entry is a dict.
From openapi docs on netbox api/docs endpoint:

                "assigned_object": {
                    "title": "Assigned object",
                    "type": "object",
                    "additionalProperties": {
                        "type": "string",
                        "x-nullable": true
                    },
                    "readOnly": true
                },

Expected Behavior

An openapi spec that mirrors the data formats used by netbox in it's publicly facing endpoints (ie: webhooks)

Observed Behavior

FastAPI raises 422 error

Originally created by @jeremypng on GitHub (Sep 5, 2022). ### NetBox version v3.3.1 ### Python version 3.8 ### Steps to Reproduce 1. Generate pydantic class from openapi spec, attach to FastAPI server 2. Configure webhook to fire on changed IPAddress object 3. FastAPI responds w/ 422 unprocessable entity Received JSON from Netbox for data.assigned_object looks like this: ```json { 'id'= 4, 'url'= '/api/dcim/interfaces/4/', 'display'= 'Loopback0', 'device'= { 'id'= 4, 'url'= '/api/dcim/devices/4/', 'display'= 'pez_simulator', 'name'= 'pez_simulator' }, 'name'= 'Loopback0', 'cable'= None, '_occupied'= False } ``` The openapi definition from the apidocs endpoint specifies that each property in the dict for assigned_object be a string. But the device entry is a dict. From openapi docs on netbox api/docs endpoint: ``` "assigned_object": { "title": "Assigned object", "type": "object", "additionalProperties": { "type": "string", "x-nullable": true }, "readOnly": true }, ``` ### Expected Behavior An openapi spec that mirrors the data formats used by netbox in it's publicly facing endpoints (ie: webhooks) ### Observed Behavior FastAPI raises 422 error
adam added the type: bugstatus: duplicate labels 2025-12-29 19:46:58 +01:00
adam closed this issue 2025-12-29 19:46:58 +01:00
Author
Owner

@amhn commented on GitHub (Sep 6, 2022):

This is similar to #9895. Should be fixed in 3.3.2

@amhn commented on GitHub (Sep 6, 2022): This is similar to #9895. Should be fixed in 3.3.2
Author
Owner

@jeremystretch commented on GitHub (Sep 6, 2022):

As @amhn notes this has likely already been addressed in v3.3.2. Please try upgrading to that release. If you continue to encounter issues with the OpenAPI definition, you're welcome to request that this issue be re-opened.

  1. Generate pydantic class from openapi spec, attach to FastAPI server

Just an FYI for the future, we can't accept bug reports that rely on the use of external tools. In this particular case, it's sufficient to just point out the error in the OpenAPI definition.

@jeremystretch commented on GitHub (Sep 6, 2022): As @amhn notes this has likely already been addressed in v3.3.2. Please try upgrading to that release. If you continue to encounter issues with the OpenAPI definition, you're welcome to request that this issue be re-opened. > 1. Generate pydantic class from openapi spec, attach to FastAPI server Just an FYI for the future, we can't accept bug reports that rely on the use of external tools. In this particular case, it's sufficient to just point out the error in the OpenAPI definition.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6935