Generating OpenAPI schema triggers multiple warnings and errors #11618

Closed
opened 2025-12-29 21:47:42 +01:00 by adam · 2 comments
Owner

Originally created by @jeremystretch on GitHub (Sep 16, 2025).

Originally assigned to: @pheus on GitHub.

NetBox Edition

NetBox Community

NetBox Version

v4.4.0

Python Version

3.12

Steps to Reproduce

  1. Generate the OpenAPI schema locally with the following management command:
./manage.py spectacular --format openapi-json > openapi.json

Expected Behavior

The OpenAPI schema should be generated without any warnings or errors.

Observed Behavior

Although the schema is generated, the following warnings and errors are reported:

/home/jstretch/projects/netbox/netbox/core/api/views.py:182: Warning [BackgroundTaskViewSet]: could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:id>) or annotating the parameter type with @extend_schema. Defaulting to "string".
/home/jstretch/projects/netbox/netbox/core/api/views.py:182: Error [BackgroundTaskViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'BackgroundTaskViewSet' object has no attribute 'get_serializer_class')
/home/jstretch/projects/netbox/netbox/core/api/views.py:156: Error [BackgroundWorkerViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'BackgroundWorkerViewSet' object has no attribute 'get_serializer_class')
/home/jstretch/projects/netbox/netbox/core/api/views.py:156: Warning [BackgroundWorkerViewSet]: could not derive type of path parameter "name" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:name>) or annotating the parameter type with @extend_schema. Defaulting to "string".
/home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1045: Warning [DeviceViewSet > DeviceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1914: Error [InterfaceViewSet > InterfaceFilterSet]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [InterfaceViewSet > InterfaceSerializer > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [InterfaceViewSet > WritableInterfaceSerializer > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [MACAddressViewSet > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1348: Warning [VirtualDeviceContextViewSet > VirtualDeviceContextFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldChoiceSetViewSet > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string.
/home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldViewSet > CustomFieldSerializer > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string.
/home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldViewSet > WritableCustomFieldSerializer > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string.
/home/jstretch/projects/netbox/netbox/ipam/filtersets.py:1166: Warning [ServiceViewSet > ServiceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/ipam/filtersets.py:950: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "interface_id" in model. Defaulting to string.
/home/jstretch/projects/netbox/netbox/ipam/filtersets.py:950: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "vminterface_id" in model. Defaulting to string.
/home/jstretch/projects/netbox/netbox/virtualization/filtersets.py:238: Error [VMInterfaceViewSet > VMInterfaceFilterSet]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string"
/home/jstretch/projects/netbox/netbox/virtualization/filtersets.py:82: Warning [VirtualMachineViewSet > VirtualMachineFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string"
Warning: operationId "core_background_queues_retrieve" has collisions [('/api/core/background-queues/', 'get'), ('/api/core/background-queues/{name}/', 'get')]. resolving with numeral suffixes.
Warning: operationId "core_background_tasks_retrieve" has collisions [('/api/core/background-tasks/', 'get'), ('/api/core/background-tasks/{id}/', 'get')]. resolving with numeral suffixes.
Warning: operationId "core_background_workers_retrieve" has collisions [('/api/core/background-workers/', 'get'), ('/api/core/background-workers/{name}/', 'get')]. resolving with numeral suffixes.

Schema generation summary:
Warnings: 29 (14 unique)
Errors:   29 (7 unique)
Originally created by @jeremystretch on GitHub (Sep 16, 2025). Originally assigned to: @pheus on GitHub. ### NetBox Edition NetBox Community ### NetBox Version v4.4.0 ### Python Version 3.12 ### Steps to Reproduce 1. Generate the OpenAPI schema locally with the following management command: ``` ./manage.py spectacular --format openapi-json > openapi.json ``` ### Expected Behavior The OpenAPI schema should be generated without any warnings or errors. ### Observed Behavior Although the schema is generated, the following warnings and errors are reported: ``` /home/jstretch/projects/netbox/netbox/core/api/views.py:182: Warning [BackgroundTaskViewSet]: could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:id>) or annotating the parameter type with @extend_schema. Defaulting to "string". /home/jstretch/projects/netbox/netbox/core/api/views.py:182: Error [BackgroundTaskViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'BackgroundTaskViewSet' object has no attribute 'get_serializer_class') /home/jstretch/projects/netbox/netbox/core/api/views.py:156: Error [BackgroundWorkerViewSet]: exception raised while getting serializer. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: 'BackgroundWorkerViewSet' object has no attribute 'get_serializer_class') /home/jstretch/projects/netbox/netbox/core/api/views.py:156: Warning [BackgroundWorkerViewSet]: could not derive type of path parameter "name" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. <int:name>) or annotating the parameter type with @extend_schema. Defaulting to "string". /home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1045: Warning [DeviceViewSet > DeviceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string" /home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1914: Error [InterfaceViewSet > InterfaceFilterSet]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string" /home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [InterfaceViewSet > InterfaceSerializer > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string" /home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [InterfaceViewSet > WritableInterfaceSerializer > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string" /home/jstretch/projects/netbox/netbox/dcim/api/serializers_/devices.py:162: Error [MACAddressViewSet > MACAddressSerializer]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string" /home/jstretch/projects/netbox/netbox/dcim/filtersets.py:1348: Warning [VirtualDeviceContextViewSet > VirtualDeviceContextFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string" /home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldChoiceSetViewSet > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string. /home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldViewSet > CustomFieldSerializer > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string. /home/jstretch/projects/netbox/netbox/extras/api/serializers_/customfields.py:18: Warning [CustomFieldViewSet > WritableCustomFieldSerializer > CustomFieldChoiceSetSerializer]: unable to resolve type hint for function "choices_count". Consider using a type hint or @extend_schema_field. Defaulting to string. /home/jstretch/projects/netbox/netbox/ipam/filtersets.py:1166: Warning [ServiceViewSet > ServiceFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string" /home/jstretch/projects/netbox/netbox/ipam/filtersets.py:950: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "interface_id" in model. Defaulting to string. /home/jstretch/projects/netbox/netbox/ipam/filtersets.py:950: Warning [VLANViewSet > VLANFilterSet]: Unable to guess choice types from values, filter method's type hint or find "vminterface_id" in model. Defaulting to string. /home/jstretch/projects/netbox/netbox/virtualization/filtersets.py:238: Error [VMInterfaceViewSet > VMInterfaceFilterSet]: could not resolve model field "dcim.MACAddress.mac_address". Failed to resolve through serializer_field_mapping, get_internal_type(), or any override mechanism. Defaulting to "string" /home/jstretch/projects/netbox/netbox/virtualization/filtersets.py:82: Warning [VirtualMachineViewSet > VirtualMachineFilterSet]: model field "IPAddressField" has no mapping in ModelSerializer. It may be a deprecated field. Defaulting to "string" Warning: operationId "core_background_queues_retrieve" has collisions [('/api/core/background-queues/', 'get'), ('/api/core/background-queues/{name}/', 'get')]. resolving with numeral suffixes. Warning: operationId "core_background_tasks_retrieve" has collisions [('/api/core/background-tasks/', 'get'), ('/api/core/background-tasks/{id}/', 'get')]. resolving with numeral suffixes. Warning: operationId "core_background_workers_retrieve" has collisions [('/api/core/background-workers/', 'get'), ('/api/core/background-workers/{name}/', 'get')]. resolving with numeral suffixes. Schema generation summary: Warnings: 29 (14 unique) Errors: 29 (7 unique) ```
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:47:42 +01:00
adam closed this issue 2025-12-29 21:47:42 +01:00
Author
Owner

@pheus commented on GitHub (Sep 21, 2025):

I’d like to contribute this fix. Could you please assign the issue to me? Thanks!

@pheus commented on GitHub (Sep 21, 2025): I’d like to contribute this fix. Could you please assign the issue to me? Thanks!
Author
Owner

@jnovinger commented on GitHub (Sep 22, 2025):

Thanks, @pheus , it's all yours.

@jnovinger commented on GitHub (Sep 22, 2025): Thanks, @pheus , it's all yours.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11618