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.
947 lines
38 KiB
947 lines
38 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_count": 2,
|
|
"children": [
|
|
{
|
|
"id": 2,
|
|
"name": "Surah Al-Fatiha",
|
|
"hadis_count": 25,
|
|
"has_hadis": True,
|
|
"order": 1,
|
|
"xmind_file": None,
|
|
"has_xmind_file": False,
|
|
"children_count": 0,
|
|
"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_count": 0,
|
|
"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_count": 2,
|
|
"children": [
|
|
{
|
|
"id": 5,
|
|
"name": "Book of Faith",
|
|
"hadis_count": 50,
|
|
"has_hadis": True,
|
|
"order": 1,
|
|
"xmind_file": None,
|
|
"has_xmind_file": False,
|
|
"children_count": 0,
|
|
"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_count": 0,
|
|
"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")
|
|
}
|
|
)
|
|
|
|
|
|
# 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",
|
|
operation_summary="List Transmitters",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'status',
|
|
openapi.IN_QUERY,
|
|
description='Filter by reliability status (very_reliable, reliable, acceptable, weak, very_weak, unknown)',
|
|
type=openapi.TYPE_STRING,
|
|
required=False
|
|
),
|
|
openapi.Parameter(
|
|
'madhhab',
|
|
openapi.IN_QUERY,
|
|
description='Filter by madhhab/school (shia, sunni, hanafi, maliki, shafii, hanbali, other, unknown)',
|
|
type=openapi.TYPE_STRING,
|
|
required=False
|
|
),
|
|
openapi.Parameter(
|
|
'generation',
|
|
openapi.IN_QUERY,
|
|
description='Filter by generation (1-10 representing narrator layers/classes)',
|
|
type=openapi.TYPE_INTEGER,
|
|
required=False
|
|
),
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of transmitters with optional filtering applied",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 1,
|
|
"full_name": "Abu Daud Sulaiman ibn al-Ash'ath al-Azdi al-Sijistani",
|
|
"birth_year_hijri": 202,
|
|
"death_year_hijri": 275,
|
|
"description": "Imam Abu Daud, compiler of Sunan Abu Daud, one of the six major hadith collections"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"full_name": "Muhammad ibn Isma'il al-Bukhari",
|
|
"birth_year_hijri": 194,
|
|
"death_year_hijri": 256,
|
|
"description": "Imam Bukhari, compiler of Sahih al-Bukhari, the most authentic hadith collection"
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for TransmitterDetailView
|
|
transmitter_detail_swagger = swagger_auto_schema(
|
|
operation_description="Get detailed information about a specific transmitter including their scholarly opinions and hadith transmissions",
|
|
operation_summary="Get Transmitter Details",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'transmitters_id',
|
|
openapi.IN_PATH,
|
|
description="ID of the transmitter",
|
|
type=openapi.TYPE_INTEGER,
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="Detailed transmitter information with nested opinions and transmissions",
|
|
examples={
|
|
"application/json": {
|
|
"id": 1,
|
|
"full_name": "Abu Daud Sulaiman ibn al-Ash'ath al-Azdi al-Sijistani",
|
|
"kunya": "Abu Daud",
|
|
"known_as": "Imam Abu Daud",
|
|
"nickname": "Al-Sijistani",
|
|
"origin": "Sijistan (modern Sistan)",
|
|
"lived_in": "Basra, Baghdad",
|
|
"died_in": "Basra",
|
|
"birth_year_hijri": 202,
|
|
"death_year_hijri": 275,
|
|
"age_at_death": 73,
|
|
"reliability": "very_reliable",
|
|
"madhhab": "sunni",
|
|
"in_sahih_bukhari": False,
|
|
"in_sahih_muslim": True,
|
|
"description": "Imam Abu Daud, compiler of Sunan Abu Daud",
|
|
"thumbnail": "http://example.com/media/transmitters/abu_daud.jpg",
|
|
"opinions": [
|
|
{
|
|
"id": 1,
|
|
"scholar_name": "Ibn Hajar al-Asqalani",
|
|
"opinion_text": "Abu Daud was a reliable and trustworthy narrator",
|
|
"status": "confirmed",
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"updated_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
],
|
|
"hadis_transmissions": [
|
|
{
|
|
"id": 1,
|
|
"hadis": {
|
|
"id": 1001,
|
|
"number": 1,
|
|
"title": "The first hadith",
|
|
"category": {
|
|
"id": 1,
|
|
"title": "Book of Faith"
|
|
},
|
|
"translation": "Actions are by intentions"
|
|
},
|
|
"order": 1,
|
|
"status": "reliable",
|
|
"narrator_layer": 1,
|
|
"created_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
),
|
|
status.HTTP_404_NOT_FOUND: openapi.Response(
|
|
description="Transmitter not found"
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for BookReferencesView
|
|
book_references_list_swagger = swagger_auto_schema(
|
|
operation_description="Get list of all book references used in hadith studies including their metadata, images, and volume counts",
|
|
operation_summary="List Book References",
|
|
tags=['Hadis'],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of all book references",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 1,
|
|
"title": "Sahih al-Bukhari",
|
|
"description": "The most authentic collection of hadith compiled by Imam Bukhari",
|
|
"rate": 5.0,
|
|
"image": [
|
|
{
|
|
"id": 1,
|
|
"image": "http://example.com/media/books/bukhari_cover.jpg",
|
|
"order": 1,
|
|
"description": "Front cover of Sahih al-Bukhari",
|
|
"created_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
],
|
|
"volume_count": 9
|
|
},
|
|
{
|
|
"id": 2,
|
|
"title": "Sahih Muslim",
|
|
"description": "The second most authentic collection of hadith compiled by Imam Muslim",
|
|
"rate": 4.9,
|
|
"image": [],
|
|
"volume_count": 7
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for BookAuthorView
|
|
book_authors_list_swagger = swagger_auto_schema(
|
|
operation_description="Get list of all book authors who have contributed to hadith literature",
|
|
operation_summary="List Book Authors",
|
|
tags=['Hadis'],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of all book authors",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 1,
|
|
"name": "Muhammad ibn Isma'il al-Bukhari",
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"updated_at": "2024-01-01T00:00:00Z"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Muslim ibn al-Hajjaj al-Qushayri",
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"updated_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for BookDetailView
|
|
book_detail_swagger = swagger_auto_schema(
|
|
operation_description="Get detailed information about a specific book reference including authors, images, and related hadiths",
|
|
operation_summary="Get Book Reference Details",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'bookreference_id',
|
|
openapi.IN_PATH,
|
|
description="ID of the book reference",
|
|
type=openapi.TYPE_INTEGER,
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="Detailed book reference information",
|
|
examples={
|
|
"application/json": {
|
|
"id": 1,
|
|
"title": "Sahih al-Bukhari",
|
|
"description": "The most authentic collection of hadith compiled by Imam Bukhari",
|
|
"language": "Arabic",
|
|
"isbn": "978-1234567890",
|
|
"volume": "9 volumes",
|
|
"year_of_publication": "846",
|
|
"number_page": 4200,
|
|
"rate": 5.0,
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"updated_at": "2024-01-01T00:00:00Z",
|
|
"author": [
|
|
{
|
|
"id": 1,
|
|
"name": "Muhammad ibn Isma'il al-Bukhari",
|
|
"created_at": "2024-01-01T00:00:00Z",
|
|
"updated_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
],
|
|
"image": [
|
|
{
|
|
"id": 1,
|
|
"image": "http://example.com/media/books/bukhari_cover.jpg",
|
|
"order": 1,
|
|
"description": "Front cover of Sahih al-Bukhari",
|
|
"created_at": "2024-01-01T00:00:00Z"
|
|
}
|
|
],
|
|
"hadis": [
|
|
{
|
|
"id": 1,
|
|
"number": 1,
|
|
"title": "The first hadith about faith",
|
|
"category": {
|
|
"id": 1,
|
|
"title": "Book of Faith"
|
|
},
|
|
"translation": "Actions are by intentions"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
),
|
|
status.HTTP_404_NOT_FOUND: openapi.Response(
|
|
description="Book reference not found"
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for CategoriesView
|
|
categories_list_swagger = swagger_auto_schema(
|
|
operation_description="Get list of all hadith categories with their associated sect information",
|
|
operation_summary="List All Categories",
|
|
tags=['Hadis'],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of all hadith categories",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 1,
|
|
"title": "Book of Faith",
|
|
"sect_id": 1,
|
|
"sect_type": "sunni",
|
|
"source_type": "hadith",
|
|
"description": "Hadiths related to Islamic faith and beliefs",
|
|
"order": 1,
|
|
"slug": "book-of-faith",
|
|
"xmind_file": "http://example.com/media/xmind/faith.xmind",
|
|
"children_count": 3
|
|
},
|
|
{
|
|
"id": 2,
|
|
"title": "Book of Prayer",
|
|
"sect_id": 1,
|
|
"sect_type": "sunni",
|
|
"source_type": "hadith",
|
|
"description": "Hadiths about salah (prayer) and related rulings",
|
|
"order": 2,
|
|
"slug": "book-of-prayer",
|
|
"xmind_file": None,
|
|
"children_count": 0
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for CategoriesBySectView
|
|
categories_by_sect_swagger = swagger_auto_schema(
|
|
operation_description="Get list of hadith categories filtered by sect type (shia or sunni)",
|
|
operation_summary="List Categories by Sect",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'sect_type',
|
|
openapi.IN_PATH,
|
|
description="Type of Islamic sect (shia or sunni)",
|
|
type=openapi.TYPE_STRING,
|
|
enum=['shia', 'sunni'],
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of hadith categories filtered by sect type",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 1,
|
|
"title": "Book of Faith",
|
|
"sect_id": 1,
|
|
"sect_type": "sunni",
|
|
"source_type": "hadith",
|
|
"description": "Hadiths related to Islamic faith and beliefs",
|
|
"order": 1,
|
|
"slug": "book-of-faith",
|
|
"xmind_file": "http://example.com/media/xmind/faith.xmind",
|
|
"children_count": 3
|
|
},
|
|
{
|
|
"id": 2,
|
|
"title": "Book of Prayer",
|
|
"sect_id": 1,
|
|
"sect_type": "sunni",
|
|
"source_type": "hadith",
|
|
"description": "Hadiths about salah (prayer) and related rulings",
|
|
"order": 2,
|
|
"slug": "book-of-prayer",
|
|
"xmind_file": None,
|
|
"children_count": 0
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for HadisCategoryTreeBySectView
|
|
categories_tree_by_sect_swagger = swagger_auto_schema(
|
|
operation_description="Retrieve child categories of a specific parent category (identified by slug) within a given Islamic sect type",
|
|
operation_summary="Get Category Children by Sect and Slug",
|
|
operation_id="getCategoryChildrenBySectAndSlug",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'sect_type',
|
|
openapi.IN_PATH,
|
|
description="Type of Islamic sect (shia or sunni)",
|
|
type=openapi.TYPE_STRING,
|
|
enum=['shia', 'sunni'],
|
|
required=True
|
|
),
|
|
openapi.Parameter(
|
|
'slug',
|
|
openapi.IN_PATH,
|
|
description="URL slug of the parent category",
|
|
type=openapi.TYPE_STRING,
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of child categories belonging to the specified parent category (identified by slug) within the given sect type",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 330,
|
|
"title": "Толкование суры Аль-Фатиха",
|
|
"source_type": "quran",
|
|
"slug": "-1",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0
|
|
},
|
|
{
|
|
"id": 331,
|
|
"title": "Толкование суры Аль-Бакара",
|
|
"source_type": "quran",
|
|
"slug": "-19",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0
|
|
},
|
|
{
|
|
"id": 332,
|
|
"title": "Толкование суры Аль Имран",
|
|
"source_type": "quran",
|
|
"slug": "-33",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|
|
|
|
|
|
# Swagger documentation for HadisCategoryTreeBySectSourceView
|
|
categories_tree_by_sect_source_swagger = swagger_auto_schema(
|
|
operation_description="Retrieve child categories of a specific parent category (identified by slug) within a given Islamic sect type, additionally filtered by source material type",
|
|
operation_summary="Get Category Children by Sect, Slug and Source",
|
|
operation_id="getCategoryChildrenBySectSlugAndSource",
|
|
tags=['Hadis'],
|
|
manual_parameters=[
|
|
openapi.Parameter(
|
|
'sect_type',
|
|
openapi.IN_PATH,
|
|
description="Type of Islamic sect (shia or sunni)",
|
|
type=openapi.TYPE_STRING,
|
|
enum=['shia', 'sunni'],
|
|
required=True
|
|
),
|
|
openapi.Parameter(
|
|
'slug',
|
|
openapi.IN_PATH,
|
|
description="URL slug of the parent category",
|
|
type=openapi.TYPE_STRING,
|
|
required=True
|
|
),
|
|
openapi.Parameter(
|
|
'source_type',
|
|
openapi.IN_PATH,
|
|
description="Type of source material (quran, hadith, history, fatwa, quote)",
|
|
type=openapi.TYPE_STRING,
|
|
enum=['quran', 'hadith', 'history', 'fatwa', 'quote'],
|
|
required=True
|
|
)
|
|
],
|
|
responses={
|
|
status.HTTP_200_OK: openapi.Response(
|
|
description="List of child categories belonging to the specified parent category (identified by slug) within the given sect type, additionally filtered by source type",
|
|
examples={
|
|
"application/json": [
|
|
{
|
|
"id": 330,
|
|
"title": "Толкование суры Аль-Фатиха",
|
|
"source_type": "quran",
|
|
"slug": "-1",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0,
|
|
"has_hadis": False
|
|
},
|
|
{
|
|
"id": 331,
|
|
"title": "Толкование суры Аль-Бакара",
|
|
"source_type": "quran",
|
|
"slug": "-19",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0,
|
|
"has_hadis": False
|
|
},
|
|
{
|
|
"id": 332,
|
|
"title": "Толкование суры Аль Имран",
|
|
"source_type": "quran",
|
|
"slug": "-33",
|
|
"sect_id": 20,
|
|
"sect_type": "shia",
|
|
"children_count": 0,
|
|
"has_hadis": False
|
|
}
|
|
]
|
|
}
|
|
),
|
|
status.HTTP_500_INTERNAL_SERVER_ERROR: openapi.Response(
|
|
description="Internal server error"
|
|
)
|
|
}
|
|
)
|