7848 fix the spectacular test failure

This commit is contained in:
Arthur Hanson 2024-11-22 13:27:51 -08:00
parent 3e72d7ef07
commit 1982741e5b
2 changed files with 14 additions and 0 deletions

View File

@ -158,6 +158,11 @@ class NetBoxAutoSchema(AutoSchema):
fields = {} if hasattr(serializer, 'child') else serializer.fields
remove_fields = []
"""
If you get a failure here for: AttributeError: 'cached_property' object has no attribute 'items'
it is probably because you are using a viewsets.ViewSet for the API View and are defining a
serializer_class. You will also need to define a get_serializer function like GenericAPIView.
"""
for child_name, child in fields.items():
# read_only fields don't need to be in writable (write only) serializers
if 'read_only' in dir(child) and child.read_only:

View File

@ -104,6 +104,15 @@ class BaseRQViewSet(viewsets.ViewSet):
serializer = self.serializer_class(data, many=True, context={'request': request})
return paginator.get_paginated_response(serializer.data)
def get_serializer(self, *args, **kwargs):
"""
Return the serializer instance that should be used for validating and
deserializing input, and for serializing output.
"""
serializer_class = self.get_serializer_class()
kwargs['context'] = self.get_serializer_context()
return serializer_class(*args, **kwargs)
class BackgroundQueueViewSet(BaseRQViewSet):
"""