operation_description="Create a new custom attribute for a book. Attributes can store additional metadata about hadith books such as number of hadith, authenticity grade, or other relevant information.",
operation_summary="Create Book Attribute",
tags=['Hadis'],
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
required=['title','value','book_reference'],
properties={
'title':openapi.Schema(
type=openapi.TYPE_STRING,
description='Attribute title/name (e.g., "Number of Hadith")',
example='Collection Type'
),
'value':openapi.Schema(
type=openapi.TYPE_STRING,
description='Attribute value (e.g., "7,563")',
example='Hadith Compilation'
),
'book_reference':openapi.Schema(
type=openapi.TYPE_INTEGER,
description='ID of the book this attribute belongs to',
example=2
),
}
),
responses={
status.HTTP_201_CREATED:openapi.Response(
description="Book attribute created successfully",
examples={
"application/json":{
"id":3,
"title":"Collection Type",
"value":"Hadith Compilation",
"book_reference":2
}
}
),
status.HTTP_400_BAD_REQUEST:openapi.Response(
description="Invalid input data",
examples={
"application/json":{
"title":["This field is required."],
"value":["This field is required."],
"book_reference":["Invalid book reference ID."]
}
}
),
status.HTTP_401_UNAUTHORIZED:openapi.Response(
description="Authentication required - provide a valid token"
),
status.HTTP_403_FORBIDDEN:openapi.Response(
description="Permission denied - you do not have permission to create attributes"