diff --git a/apps/hadis/docs.py b/apps/hadis/docs.py index f617f1b..ab6b600 100644 --- a/apps/hadis/docs.py +++ b/apps/hadis/docs.py @@ -347,6 +347,84 @@ hadis_detail_swagger = swagger_auto_schema( ) +# Swagger documentation for HadisCollectionListView +hadis_collections_swagger = swagger_auto_schema( + operation_description="Get list of all active hadis collections for browsing and categorization", + operation_summary="List Hadis Collections", + operation_id="getHadisCollections", + tags=['Hadis'], + responses={ + status.HTTP_200_OK: openapi.Response( + description="List of hadis collections", + examples={ + "application/json": [ + { + "id": 1, + "title": "Collection Title", + "description": "Collection description", + "order": 1, + "status": True + } + ] + } + ), + status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response( + description="Internal server error" + ) + } +) + + +# Swagger documentation for HadisInfoView +hadis_info_swagger = swagger_auto_schema( + operation_description="Get statistical information about hadis database including counts of categories, references, bookmarks, and narrators", + operation_summary="Get Hadis Statistics", + operation_id="getHadisInfo", + tags=['Hadis'], + responses={ + status.HTTP_200_OK: openapi.Response( + description="Hadis database statistics", + examples={ + "application/json": { + "category_count": 25, + "reference_count": 150, + "bookmark_count": 75, + "narrator_count": 200 + } + } + ), + status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response( + description="Internal server error" + ) + } +) + + +# Swagger documentation for HadisSyncView +hadis_sync_swagger = swagger_auto_schema( + operation_description="Get complete hadis data for offline synchronization including all categories, hadis, and related information", + operation_summary="Sync Hadis Data", + operation_id="syncHadisData", + tags=['Hadis'], + responses={ + status.HTTP_200_OK: openapi.Response( + description="Complete hadis data for synchronization", + examples={ + "application/json": { + "categories": [], + "hadis": [], + "references": [], + "transmitters": [] + } + } + ), + status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response( + description="Internal server error" + ) + } +) + + # Swagger documentation for TransmitterView transmitter_list_swagger = swagger_auto_schema( operation_description="Get list of transmitters (narrators) with optional filtering by status, madhhab, and generation", diff --git a/apps/hadis/views/hadis.py b/apps/hadis/views/hadis.py index ecca852..495de07 100644 --- a/apps/hadis/views/hadis.py +++ b/apps/hadis/views/hadis.py @@ -5,7 +5,7 @@ from rest_framework.response import Response from ..models import HadisCategory, Hadis, HadisCollection from ..serializers import HadisListSerializer, HadisDetailSerializer, HadisCollectionListSerializer, HadisSyncSerializer -from ..docs import hadis_list_swagger, hadis_detail_swagger +from ..docs import hadis_list_swagger, hadis_detail_swagger, hadis_collections_swagger, hadis_sync_swagger class HadisCollectionListView(ListAPIView): @@ -16,6 +16,7 @@ class HadisCollectionListView(ListAPIView): serializer_class = HadisCollectionListSerializer pagination_class = NoPagination + @hadis_collections_swagger def get(self, request, *args, **kwargs): return self.list(request, *args, **kwargs) @@ -27,6 +28,8 @@ class HadisSyncView(ListAPIView): serializer_class = HadisSyncSerializer pagination_class = NoPagination + @hadis_sync_swagger + def get_queryset(self): return Hadis.objects.filter(status=True).select_related( 'category', 'hadis_status' diff --git a/apps/hadis/views/info.py b/apps/hadis/views/info.py index 64616db..b5419a9 100644 --- a/apps/hadis/views/info.py +++ b/apps/hadis/views/info.py @@ -3,6 +3,7 @@ from rest_framework.response import Response from rest_framework import status from ..models import HadisSect, BookReference, Transmitters +from ..docs import hadis_info_swagger from apps.bookmark.models import Bookmark @@ -11,6 +12,7 @@ class HadisInfoView(APIView): API view to get hadis statistics """ + @hadis_info_swagger def get(self, request, *args, **kwargs): category_count = HadisSect.objects.filter(is_active=True).count() reference_count = BookReference.objects.count()