Drf-standardized-errors not generating 404 for RetrieveAPIView
The documentation for drf-standardized-errors says that it can be integrated with DRF-Spectacular and will generate error response documentation. It specifically provides instructions on how to "Hide error responses that show in every operation", e.g. standard 404 or 401 responses.
But I haven't been able to generate 404 error responses for standard DRF views, e.g. RetrieveAPIView:
class MemberDetailsView(generics.RetrieveAPIView):
serializer_class = MemberDetailsSerializer
schema = AutoSchema()
def get_queryset(self):
member_id = self.kwargs["pk"]
cache_key = f"member_{member_id}"
cached_member = cache.get(cache_key)
if cached_member is None:
print("NO CACHE")
cached_member = TE_MemberList.objects.filter(id=self.kwargs["pk"])
cache.set(cache_key, cached_member, timeout=600)
return cached_member
It only generates a 200 response. I've looked into the code of drf-standardized-errors AutoSchema
, and noticed that it calls get_response_serializers()
method of drf-spectacular AutoSchema
, which does not have a 404 code among the responses.
If I have something like raise NotFound(detail="Object not found")
in a view, then it does generate a 404 response documentation.
Am I misunderstanding the purpose of this auto-integration?