netbox icon indicating copy to clipboard operation
netbox copied to clipboard

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

Open fabi125 opened this issue 1 year ago • 3 comments

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.

fabi125 avatar Jun 17 '24 11:06 fabi125

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 :)

fabi125 avatar Jun 17 '24 11:06 fabi125

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

jeremystretch avatar Jun 17 '24 12:06 jeremystretch

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

fabi125 avatar Jul 02 '24 15:07 fabi125