OpenAPI Specs do not match API Endpoints - specifically around Nested Object Counts #10466

Closed
opened 2025-12-29 21:31:51 +01:00 by adam · 3 comments
Owner

Originally created by @jasonbarbee on GitHub (Nov 11, 2024).

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.0.11

Python Version

3.11

Steps to Reproduce

Related Issues
https://github.com/netbox-community/netbox/issues/16670
https://github.com/netbox-community/netbox/issues/16085

To Replicate:

  1. Open Netbox Swagger

  2. Observe Schema for BriefManufacturer

  3. OpenAPI Specs define the response as including fields that are not included in the actual payload response
    devicetype_count
    image

  4. Query API as shown below.

Expected Behavior

Expected Response according to Swagger / Specs
Includes devicetype_count
image

Observed Behavior

Actual Endpoint Response
(missing devicetype_count)
image

Impact: Generated OpenAPI Models use this schema, and fail to process data correctly, since that field is expected to exist.

Other Nested Models also observed as affected

This might be separate issues, but the other Github issues linked several together around nested serialization. If I'm beyond the scope, let me know and I can remove these from the issue report, but I felt it may be worth documenting that this is bigger than just a single model. It may be more than these below.

The root cause of this seems to affects other models:
BriefDeviceType

image

Query - /dcim/device-types/281/

Note the schema - devicetype_count

image

Note the missing devicetype_count field.

image

BriefDeviceRole

image

When it is returned as part of a Nested object, notice the missing count fields that should be on the schema.
image

Originally created by @jasonbarbee on GitHub (Nov 11, 2024). ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.0.11 ### Python Version 3.11 ### Steps to Reproduce Related Issues https://github.com/netbox-community/netbox/issues/16670 https://github.com/netbox-community/netbox/issues/16085 **To Replicate:** 1. Open Netbox Swagger 2. Observe Schema for BriefManufacturer 3. OpenAPI Specs define the response as including fields that are not included in the actual payload response devicetype_count <img width="508" alt="image" src="https://github.com/user-attachments/assets/a1c42509-2a8d-4780-8228-f6ed8241bedb"> 4. Query API as shown below. ### Expected Behavior **Expected Response according to Swagger / Specs** Includes devicetype_count <img width="598" alt="image" src="https://github.com/user-attachments/assets/fe4c75f8-ac42-49bb-a9e9-21006edee88d"> ### Observed Behavior **Actual Endpoint Response** (missing devicetype_count) <img width="867" alt="image" src="https://github.com/user-attachments/assets/33949758-7e48-4c91-af6e-38cdaadee676"> **Impact:** Generated OpenAPI Models use this schema, and fail to process data correctly, since that field is expected to exist. ### Other Nested Models also observed as affected ### This might be separate issues, but the other Github issues linked several together around nested serialization. If I'm beyond the scope, let me know and I can remove these from the issue report, but I felt it may be worth documenting that this is bigger than just a single model. It may be more than these below. The root cause of this seems to affects other models: **BriefDeviceType** <img width="499" alt="image" src="https://github.com/user-attachments/assets/4611b107-1ae7-41f7-ab4f-aad4560db69e"> Query - /dcim/device-types/281/ Note the schema - devicetype_count <img width="436" alt="image" src="https://github.com/user-attachments/assets/205e3f39-620e-4824-a101-eb1def096aca"> Note the missing devicetype_count field. <img width="788" alt="image" src="https://github.com/user-attachments/assets/b5face98-dd12-4af5-bf25-a68366eb11bc"> **BriefDeviceRole** <img width="481" alt="image" src="https://github.com/user-attachments/assets/37045f50-095a-4f62-ae11-b8595fe11bc9"> When it is returned as part of a Nested object, notice the missing count fields that should be on the schema. <img width="863" alt="image" src="https://github.com/user-attachments/assets/8dd1f485-4428-4e1b-ad66-09f09ab26806">
adam added the type: bugstatus: duplicate labels 2025-12-29 21:31:51 +01:00
adam closed this issue 2025-12-29 21:31:52 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2024):

v4.0.11

I'm afraid we're no longer accepting bug reports for this release. Are you able to confirm that this happens on the current stable release of NetBox (v4.1.6)?

@jeremystretch commented on GitHub (Nov 12, 2024): > v4.0.11 I'm afraid we're no longer accepting bug reports for this release. Are you able to confirm that this happens on the current stable release of NetBox (v4.1.6)?
Author
Owner

@jasonbarbee commented on GitHub (Nov 12, 2024):

Yes, it happens in 4.1.6 also.

I have taken additional screenshots from the latest Demo Netbox instance, 4.1.6, which show the same behavior in schema vs response.

/dcim/devices/${id}
Schema - Swagger / OpenAPI schema includes the devicetype_count field
image

Response - Payload is missing the devicetype_counts
image

The 2 BriefDeviceRole counts are defined in the schema
image

The 2 BriefDeviceRole counts are missing from the response object
image

@jasonbarbee commented on GitHub (Nov 12, 2024): Yes, it happens in 4.1.6 also. I have taken additional screenshots from the latest Demo Netbox instance, 4.1.6, which show the same behavior in schema vs response. /dcim/devices/${id} **Schema - Swagger / OpenAPI schema includes the devicetype_count field** <img width="987" alt="image" src="https://github.com/user-attachments/assets/e9cb640d-ccca-47e5-8d12-6761a589d5b4"> **Response - Payload is missing the devicetype_counts** <img width="618" alt="image" src="https://github.com/user-attachments/assets/3882ef3c-ed62-42f7-8c86-6ce66fdcc080"> **The 2 BriefDeviceRole counts are defined in the schema** <img width="810" alt="image" src="https://github.com/user-attachments/assets/7df88f81-7f4d-4f1c-bcd6-1ca5ef12f59d"> **The 2 BriefDeviceRole counts are missing from the response object** <img width="601" alt="image" src="https://github.com/user-attachments/assets/3e2ca954-96f3-4155-a01c-3e32245c6e9a">
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2024):

This appears to be a duplicate of #17976.

@jeremystretch commented on GitHub (Nov 12, 2024): This appears to be a duplicate of #17976.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10466