parent_device on Device is not marked as nullable in swagger api docs #9855

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

Originally created by @fabi125 on GitHub (Jun 17, 2024).

Originally assigned to: @fabi125 on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.10

Steps to Reproduce

  1. Go to https://demo.netbox.dev/api/schema/swagger-ui/
  2. Scroll down to Device Schema and look at the parent_device field

Expected Behavior

It should contain an annotation nullable: true.

Observed Behavior

It does not contain that annotation.

The fix for this should be to add allow_null=True to SerializerMethodField here: c8aac13cee/netbox/dcim/api/serializers_/devices.py (L60)

Happy to put up a PR but it might be easier for a maintainer to just make the change and directly merge it.

Originally created by @fabi125 on GitHub (Jun 17, 2024). Originally assigned to: @fabi125 on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.0.5 ### Python Version 3.10 ### Steps to Reproduce 1. Go to https://demo.netbox.dev/api/schema/swagger-ui/ 2. Scroll down to `Device` Schema and look at the `parent_device` field ### Expected Behavior It should contain an annotation `nullable: true`. ### Observed Behavior It does not contain that annotation. The fix for this should be to add `allow_null=True` to `SerializerMethodField` here: https://github.com/netbox-community/netbox/blob/c8aac13ceebf851368f6c7c2fbc6a783fc2e7bda/netbox/dcim/api/serializers_/devices.py#L60 Happy to put up a PR but it might be easier for a maintainer to just make the change and directly merge it.
adam added the type: bugstatus: acceptedseverity: lowtopic: OpenAPI labels 2025-12-29 21:23:35 +01:00
adam closed this issue 2025-12-29 21:23:35 +01:00
Author
Owner

@fabi125 commented on GitHub (Jun 17, 2024):

Found a few more:

c8aac13cee/netbox/dcim/api/serializers_/base.py (L16-L17)

and

c8aac13cee/netbox/dcim/api/serializers_/cables.py (L94)

Thanks for looking at this :)

@fabi125 commented on GitHub (Jun 17, 2024): Found a few more: https://github.com/netbox-community/netbox/blob/c8aac13ceebf851368f6c7c2fbc6a783fc2e7bda/netbox/dcim/api/serializers_/base.py#L16-L17 and https://github.com/netbox-community/netbox/blob/c8aac13ceebf851368f6c7c2fbc6a783fc2e7bda/netbox/dcim/api/serializers_/cables.py#L94 Thanks for looking at this :)
Author
Owner

@jeremystretch commented on GitHub (Jun 17, 2024):

Thanks @fabi125, I've assigned this to you for a PR.

@jeremystretch commented on GitHub (Jun 17, 2024): Thanks @fabi125, I've assigned this to you for a PR.
Author
Owner

@fabi125 commented on GitHub (Jul 2, 2024):

I've put up #16627 a while ago in case you missed it. Thanks!

@fabi125 commented on GitHub (Jul 2, 2024): I've put up #16627 a while ago in case you missed it. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9855