netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.38k stars 2.49k forks source link

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

Open fabi125 opened 2 weeks ago

fabi125 commented 2 weeks ago

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 commented 2 weeks ago

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

jeremystretch commented 2 weeks ago

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

fabi125 commented 5 days ago

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