nautobot-app-golden-config icon indicating copy to clipboard operation
nautobot-app-golden-config copied to clipboard

drf_spectacular complaint during Nautobot startup

Open glennmatthews opened this issue 7 months ago • 0 comments

Environment

  • Python version:
  • Nautobot version: 2.0.3
  • nautobot-golden-config version: 2.0.0

Observed Behavior

?: (drf_spectacular.W001) /opt/nautobot/.local/lib/python3.11/site-packages/nautobot_golden_config/api/serializers.py: Warning [ConfigToPushViewSet > ConfigToPushSerializer]: unable to resolve type hint for function "get_config". Consider using a type hint or @extend_schema_field. Defaulting to string.

This is because drf-spectacular can't guess what type of data the config field on the serializer corresponds to.

Likely the correct fix is to from drf_spectacular.utils import extend_schema_field and then add @extend_schema_field({"type": "string"}) decorator to the get_config() method, but please verify that this does in fact return a string and not, say, a dictionary.

Additionally, there's a second warning:

?: (drf_spectacular.W002) /opt/nautobot/.local/lib/python3.11/site-packages/nautobot_golden_config/api/views.py: Error [SOTAggDeviceDetailView]: unable to guess serializer. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. Either way you may want to add a serializer_class (or method). Ignoring view for now.

This one may be trickier to address because it looks like SOTAggDeviceDetailView isn't a typical REST API view with a serializer class.

Steps to Reproduce

  1. Start Nautobot with this app enabled

glennmatthews avatar Nov 10 '23 21:11 glennmatthews