You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
341 lines
15 KiB
341 lines
15 KiB
from drf_yasg.utils import swagger_auto_schema
|
|
from drf_yasg import openapi
|
|
from rest_framework import status
|
|
|
|
|
|
# Swagger documentation for HadisSectListView
|
|
hadis_sect_list_swagger = swagger_auto_schema(
|
|
operation_description="Get list of all active Hadis sects grouped by sect type (Shia/Sunni)",
|
|
operation_summary="List Hadis Sects",
|
|
tags=['Hadis'],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of hadis sects grouped by type with count",
|
|
examples={
|
|
"application/json": {
|
|
"count": 4,
|
|
"results": {
|
|
"shia": [
|
|
{
|
|
"id": 1,
|
|
"title": "Twelver Shia",
|
|
"seo_field": None
|
|
},
|
|
{
|
|
"id": 2,
|
|
"title": "Ismaili Shia",
|
|
"seo_field": None
|
|
}
|
|
],
|
|
"sunni": [
|
|
{
|
|
"id": 3,
|
|
"title": "Hanafi",
|
|
"seo_field": None
|
|
},
|
|
{
|
|
"id": 4,
|
|
"title": "Maliki",
|
|
"seo_field": None
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for HadisCategoryTreeView
|
|
hadis_category_tree_swagger = swagger_auto_schema(
|
|
operation_description="Get hierarchical tree structure of Hadis categories for a specific sect, grouped by source type (Quran/Hadith)",
|
|
operation_summary="Get Hadis Category Tree by Sect",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'sect_id',
|
|
openapi.IN_PATH,
|
|
description="ID of the Hadis sect",
|
|
type=openapi.TYPE_INTEGER,
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="Hierarchical tree structure of categories with total count",
|
|
examples={
|
|
"application/json": {
|
|
"count": 6,
|
|
"results": {
|
|
"quran": [
|
|
{
|
|
"id": 1,
|
|
"name": "Tafsir",
|
|
"hadis_count": 150,
|
|
"has_hadis": False,
|
|
"order": 1,
|
|
"xmind_file": "http://example.com/media/xmind/tafsir.xmind",
|
|
"has_xmind_file": True,
|
|
"children": [
|
|
{
|
|
"id": 2,
|
|
"name": "Surah Al-Fatiha",
|
|
"hadis_count": 25,
|
|
"has_hadis": True,
|
|
"order": 1,
|
|
"xmind_file": None,
|
|
"has_xmind_file": False,
|
|
"children": []
|
|
},
|
|
{
|
|
"id": 3,
|
|
"name": "Surah Al-Baqarah",
|
|
"hadis_count": 125,
|
|
"has_hadis": True,
|
|
"order": 2,
|
|
"xmind_file": "http://example.com/media/xmind/baqarah.xmind",
|
|
"has_xmind_file": True,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"hadith": [
|
|
{
|
|
"id": 4,
|
|
"name": "Sahih Bukhari",
|
|
"hadis_count": 300,
|
|
"has_hadis": False,
|
|
"order": 1,
|
|
"xmind_file": "http://example.com/media/xmind/bukhari.xmind",
|
|
"has_xmind_file": True,
|
|
"children": [
|
|
{
|
|
"id": 5,
|
|
"name": "Book of Faith",
|
|
"hadis_count": 50,
|
|
"has_hadis": True,
|
|
"order": 1,
|
|
"xmind_file": None,
|
|
"has_xmind_file": False,
|
|
"children": []
|
|
},
|
|
{
|
|
"id": 6,
|
|
"name": "Book of Prayer",
|
|
"hadis_count": 250,
|
|
"has_hadis": True,
|
|
"order": 2,
|
|
"xmind_file": "http://example.com/media/xmind/prayer.xmind",
|
|
"has_xmind_file": True,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
),
|
|
status.HTTP_404_NOT_FOUND: openapi.Response(
|
|
description="Sect not found"
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for HadisListView
|
|
hadis_list_swagger = swagger_auto_schema(
|
|
operation_description="Get paginated list of Hadis for a specific category with translations based on request language",
|
|
operation_summary="List Hadis by Category",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'category_id',
|
|
openapi.IN_PATH,
|
|
description="ID of the Hadis category",
|
|
type=openapi.TYPE_INTEGER,
|
|
required=True
|
|
),
|
|
openapi.Parameter(
|
|
'page',
|
|
openapi.IN_QUERY,
|
|
description="Page number for pagination",
|
|
type=openapi.TYPE_INTEGER,
|
|
required=False
|
|
),
|
|
openapi.Parameter(
|
|
'Accept-Language',
|
|
openapi.IN_HEADER,
|
|
description="Language code for translations (en, fa, ar, ur)",
|
|
type=openapi.TYPE_STRING,
|
|
required=False,
|
|
default='en'
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="Paginated list of hadis",
|
|
examples={
|
|
"application/json": {
|
|
"count": 150,
|
|
"next": "http://example.com/api/hadis/category/1/hadis/?page=2",
|
|
"previous": None,
|
|
"results": [
|
|
{
|
|
"id": 1,
|
|
"number": 1,
|
|
"title": "The first hadis about faith",
|
|
"category": {
|
|
"id": 1,
|
|
"title": "Book of Faith"
|
|
},
|
|
"translation": "This is the English translation of the hadis"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"number": 2,
|
|
"title": "The second hadis about prayer",
|
|
"category": {
|
|
"id": 1,
|
|
"title": "Book of Faith"
|
|
},
|
|
"translation": "This is the English translation of the second hadis"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
),
|
|
status.HTTP_404_NOT_FOUND: openapi.Response(
|
|
description="Category not found"
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
hadis_detail_swagger = swagger_auto_schema(
|
|
operation_summary="Get Hadis Details",
|
|
operation_description="Retrieve detailed information about a specific hadis including status, tags, transmitters, and references",
|
|
tags=['Hadis'],
|
|
responses={
|
|
200: openapi.Response(
|
|
description="Hadis details retrieved successfully",
|
|
schema=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER, description='Hadis ID'),
|
|
'number': openapi.Schema(type=openapi.TYPE_INTEGER, description='Hadis number'),
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING, description='Hadis title'),
|
|
'text': openapi.Schema(type=openapi.TYPE_STRING, description='Arabic text of hadis'),
|
|
'translation': openapi.Schema(type=openapi.TYPE_STRING, description='Translation in request language'),
|
|
'explanation': openapi.Schema(type=openapi.TYPE_STRING, description='Detailed explanation'),
|
|
'address': openapi.Schema(type=openapi.TYPE_STRING, description='Source address'),
|
|
'hadis_status_text': openapi.Schema(type=openapi.TYPE_STRING, description='Status description'),
|
|
'links': openapi.Schema(
|
|
type=openapi.TYPE_ARRAY,
|
|
items=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'link': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
),
|
|
description='Related links'
|
|
),
|
|
'status': openapi.Schema(type=openapi.TYPE_BOOLEAN, description='Active status'),
|
|
'category': openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'category_type': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
),
|
|
'hadis_status': openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'color': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
),
|
|
'tags': openapi.Schema(
|
|
type=openapi.TYPE_ARRAY,
|
|
items=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
)
|
|
),
|
|
'transmitters': openapi.Schema(
|
|
type=openapi.TYPE_ARRAY,
|
|
items=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'order': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'is_gap': openapi.Schema(type=openapi.TYPE_BOOLEAN),
|
|
'transmitter': openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'full_name': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'birth_year_hijri': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'death_year_hijri': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'description': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
)
|
|
}
|
|
)
|
|
),
|
|
'references': openapi.Schema(
|
|
type=openapi.TYPE_ARRAY,
|
|
items=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'page_number': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'hadis_number_in_book': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'description': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'book': openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'summary_title': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'publisher': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'year_of_publication': openapi.Schema(type=openapi.TYPE_STRING)
|
|
}
|
|
),
|
|
'images': openapi.Schema(
|
|
type=openapi.TYPE_ARRAY,
|
|
items=openapi.Schema(
|
|
type=openapi.TYPE_OBJECT,
|
|
properties={
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER),
|
|
'thumbnail': openapi.Schema(type=openapi.TYPE_STRING),
|
|
'priority': openapi.Schema(type=openapi.TYPE_INTEGER)
|
|
}
|
|
)
|
|
)
|
|
}
|
|
)
|
|
)
|
|
}
|
|
)
|
|
),
|
|
404: openapi.Response(description="Hadis not found")
|
|
}
|
|
)
|