Skip to content

Commit

Permalink
fix: swagger docs missing queryset issue
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 29, 2025
1 parent 95c475c commit 37928e0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openedx_tagging/core/tagging/rest_api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ def get_serializer_context(self):
context['request'] = self.request
serializer = self.serializer_class(self, context=context)

if getattr(self, 'swagger_fake_view', False):
# queryset just for schema generation metadata
return context
# Instead of checking permissions for each TagData instance, we just check them once for the whole taxonomy
# (since that's currently how our rules work). This might change if Tag-specific permissions are needed.
taxonomy = self.get_taxonomy()
Expand All @@ -814,6 +817,9 @@ def get_queryset(self) -> TagDataQuerySet:
"""
Builds and returns the queryset to be paginated.
"""
if getattr(self, 'swagger_fake_view', False):
# queryset just for schema generation metadata
return Taxonomy.objects.none() # type: ignore[return-value]
taxonomy = self.get_taxonomy()
parent_tag_value = self.request.query_params.get("parent_tag", None)
include_counts = "include_counts" in self.request.query_params
Expand Down

0 comments on commit 37928e0

Please sign in to comment.