|
|
|
@ -17,22 +17,6 @@ collection_id_param = openapi.Parameter( |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
middle_param = openapi.Parameter( |
|
|
|
'middle', |
|
|
|
openapi.IN_QUERY, |
|
|
|
description="Filter books by middle section collection (any value will trigger the filter)", |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
bottom_param = openapi.Parameter( |
|
|
|
'bottom', |
|
|
|
openapi.IN_QUERY, |
|
|
|
description="Filter books by bottom section collection (any value will trigger the filter)", |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
is_bookmark_param = openapi.Parameter( |
|
|
|
'is_bookmark', |
|
|
|
openapi.IN_QUERY, |
|
|
|
@ -49,6 +33,14 @@ category_param = openapi.Parameter( |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
author_param = openapi.Parameter( |
|
|
|
'author', |
|
|
|
openapi.IN_QUERY, |
|
|
|
description="Filter books by author slug", |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
sort_param = openapi.Parameter( |
|
|
|
'sort', |
|
|
|
openapi.IN_QUERY, |
|
|
|
@ -65,44 +57,45 @@ search_param = openapi.Parameter( |
|
|
|
required=False |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
thumbs_schema = openapi.Schema( |
|
|
|
type=openapi.TYPE_OBJECT, |
|
|
|
nullable=True, |
|
|
|
properties={ |
|
|
|
'sm': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'md': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'lg': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
author_summary_schema = openapi.Schema( |
|
|
|
type=openapi.TYPE_OBJECT, |
|
|
|
properties={ |
|
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER), |
|
|
|
'full_name': openapi.Schema(type=openapi.TYPE_STRING), |
|
|
|
'slug': openapi.Schema(type=openapi.TYPE_STRING), |
|
|
|
'thumbnail': thumbs_schema, |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
# Response schemas |
|
|
|
book_schema = openapi.Schema( |
|
|
|
type=openapi.TYPE_OBJECT, |
|
|
|
properties={ |
|
|
|
'id': openapi.Schema( |
|
|
|
type=openapi.TYPE_INTEGER, |
|
|
|
description="Unique identifier for the book" |
|
|
|
), |
|
|
|
'title': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="Title of the book" |
|
|
|
), |
|
|
|
'slug': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="URL-friendly slug for the book" |
|
|
|
), |
|
|
|
'summary': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="Brief summary of the book" |
|
|
|
), |
|
|
|
'description': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="Detailed description of the book" |
|
|
|
), |
|
|
|
'thumbnail_url': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="URL to the book's thumbnail image", |
|
|
|
nullable=True |
|
|
|
), |
|
|
|
'author': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="Author of the book" |
|
|
|
), |
|
|
|
'language': openapi.Schema( |
|
|
|
type=openapi.TYPE_INTEGER, |
|
|
|
description="Language ID of the book", |
|
|
|
nullable=True |
|
|
|
), |
|
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER, description="Unique identifier for the book"), |
|
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING, description="Title of the book"), |
|
|
|
'slug': openapi.Schema(type=openapi.TYPE_STRING, description="URL-friendly slug for the book"), |
|
|
|
'summary': openapi.Schema(type=openapi.TYPE_STRING, description="Brief summary of the book"), |
|
|
|
'summary_title': openapi.Schema(type=openapi.TYPE_STRING, description="Summary title", nullable=True), |
|
|
|
'slogan': openapi.Schema(type=openapi.TYPE_STRING, description="Short slogan", nullable=True), |
|
|
|
'thumbnail': thumbs_schema, |
|
|
|
'author': openapi.Schema(type=openapi.TYPE_STRING, description="Author full name", nullable=True), |
|
|
|
'author_detail': author_summary_schema, |
|
|
|
'publisher': openapi.Schema(type=openapi.TYPE_STRING, description="Publisher", nullable=True), |
|
|
|
'year_of_publication': openapi.Schema(type=openapi.TYPE_STRING, description="Year of publication", nullable=True), |
|
|
|
'isbn': openapi.Schema(type=openapi.TYPE_STRING, description="ISBN", nullable=True), |
|
|
|
'numnber_of_volume': openapi.Schema(type=openapi.TYPE_STRING, description="Volume number", nullable=True), |
|
|
|
'language': openapi.Schema(type=openapi.TYPE_STRING, description="Language code", nullable=True), |
|
|
|
'main_themes': openapi.Schema( |
|
|
|
type=openapi.TYPE_ARRAY, |
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING), |
|
|
|
@ -113,36 +106,14 @@ book_schema = openapi.Schema( |
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING), |
|
|
|
description="List of notable works" |
|
|
|
), |
|
|
|
'status': openapi.Schema( |
|
|
|
type=openapi.TYPE_BOOLEAN, |
|
|
|
description="Whether the book is active/visible" |
|
|
|
), |
|
|
|
'pin': openapi.Schema( |
|
|
|
type=openapi.TYPE_BOOLEAN, |
|
|
|
description="Whether the book is pinned to the top" |
|
|
|
), |
|
|
|
'view_count': openapi.Schema( |
|
|
|
type=openapi.TYPE_INTEGER, |
|
|
|
description="Number of views for the book" |
|
|
|
), |
|
|
|
'download_count': openapi.Schema( |
|
|
|
type=openapi.TYPE_INTEGER, |
|
|
|
description="Number of downloads for the book" |
|
|
|
), |
|
|
|
'file_type': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="Type of the book file (PDF, EPUB, etc.)" |
|
|
|
), |
|
|
|
'book_file': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
description="URL to the book file", |
|
|
|
nullable=True |
|
|
|
), |
|
|
|
'created_at': openapi.Schema( |
|
|
|
type=openapi.TYPE_STRING, |
|
|
|
format=openapi.FORMAT_DATETIME, |
|
|
|
description="Creation timestamp" |
|
|
|
) |
|
|
|
'status': openapi.Schema(type=openapi.TYPE_BOOLEAN, description="Whether the book is active/visible"), |
|
|
|
'pin': openapi.Schema(type=openapi.TYPE_BOOLEAN, description="Whether the book is pinned to the top"), |
|
|
|
'view_count': openapi.Schema(type=openapi.TYPE_INTEGER, description="Number of views for the book"), |
|
|
|
'download_count': openapi.Schema(type=openapi.TYPE_INTEGER, description="Number of downloads for the book"), |
|
|
|
'file_type': openapi.Schema(type=openapi.TYPE_STRING, description="Type of the book file (PDF, EPUB, etc.)"), |
|
|
|
'book_file': openapi.Schema(type=openapi.TYPE_STRING, description="URL to the book file", nullable=True), |
|
|
|
'created_at': openapi.Schema(type=openapi.TYPE_STRING, format=openapi.FORMAT_DATETIME, description="Creation timestamp"), |
|
|
|
'share_link': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
}, |
|
|
|
required=['id', 'title', 'slug', 'status', 'created_at'] |
|
|
|
) |
|
|
|
@ -155,38 +126,61 @@ books_response = openapi.Response( |
|
|
|
'count': openapi.Schema(type=openapi.TYPE_INTEGER), |
|
|
|
'next': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'previous': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'results': openapi.Schema( |
|
|
|
type=openapi.TYPE_ARRAY, |
|
|
|
items=book_schema |
|
|
|
) |
|
|
|
'results': openapi.Schema(type=openapi.TYPE_ARRAY, items=book_schema), |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
# Book detail response |
|
|
|
book_detail_response = openapi.Response( |
|
|
|
description="Detailed information about a specific book", |
|
|
|
schema=book_schema |
|
|
|
) |
|
|
|
|
|
|
|
# Swagger decorators for views |
|
|
|
author_schema = openapi.Schema( |
|
|
|
type=openapi.TYPE_OBJECT, |
|
|
|
properties={ |
|
|
|
'id': openapi.Schema(type=openapi.TYPE_INTEGER, description="Unique identifier for the author"), |
|
|
|
'full_name': openapi.Schema(type=openapi.TYPE_STRING, description="Full name of the author"), |
|
|
|
'slug': openapi.Schema(type=openapi.TYPE_STRING, description="URL-friendly slug for the author"), |
|
|
|
'thumbnail': thumbs_schema, |
|
|
|
'birth_date': openapi.Schema(type=openapi.TYPE_STRING, format=openapi.FORMAT_DATE, nullable=True, description="Birth date"), |
|
|
|
'death_date': openapi.Schema(type=openapi.TYPE_STRING, format=openapi.FORMAT_DATE, nullable=True, description="Death date"), |
|
|
|
'books_count': openapi.Schema(type=openapi.TYPE_INTEGER, description="Number of active books"), |
|
|
|
}, |
|
|
|
required=['id', 'full_name', 'slug', 'books_count'] |
|
|
|
) |
|
|
|
|
|
|
|
authors_response = openapi.Response( |
|
|
|
description="List of authors with pagination", |
|
|
|
schema=openapi.Schema( |
|
|
|
type=openapi.TYPE_OBJECT, |
|
|
|
properties={ |
|
|
|
'count': openapi.Schema(type=openapi.TYPE_INTEGER), |
|
|
|
'next': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'previous': openapi.Schema(type=openapi.TYPE_STRING, nullable=True), |
|
|
|
'results': openapi.Schema(type=openapi.TYPE_ARRAY, items=author_schema), |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
author_detail_response = openapi.Response( |
|
|
|
description="Detailed information about a specific author", |
|
|
|
schema=author_schema |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
book_detail_swagger = swagger_auto_schema( |
|
|
|
operation_id="get_book_detail", |
|
|
|
operation_description=""" |
|
|
|
Retrieve detailed information about a specific book. |
|
|
|
|
|
|
|
This endpoint returns comprehensive information about a book, including: |
|
|
|
- Basic book details (title, slug, summary, description) |
|
|
|
- Thumbnail image URL |
|
|
|
- Basic book details |
|
|
|
- Thumbnail image URLs |
|
|
|
- Author information |
|
|
|
- Status and pin information |
|
|
|
- View and download counts |
|
|
|
- File type and book file URL |
|
|
|
- Creation and update timestamps |
|
|
|
- Categories and collections the book belongs to |
|
|
|
- Number of pages |
|
|
|
|
|
|
|
The book is specified by its slug in the URL path. |
|
|
|
""", |
|
|
|
operation_summary="Get Book Detail", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
@ -203,29 +197,17 @@ book_list_swagger = swagger_auto_schema( |
|
|
|
operation_description=""" |
|
|
|
Retrieve a list of books with filtering and search capabilities. |
|
|
|
|
|
|
|
This endpoint returns a paginated list of books. Each book includes its title, slug, |
|
|
|
summary, description, thumbnail, author, status, pin, view count, download count, |
|
|
|
file type, book file URL, and creation timestamp. |
|
|
|
|
|
|
|
You can filter books by: |
|
|
|
- Collection ID using the query parameter 'collection_id' |
|
|
|
- Category slug(s) using the query parameter 'category' (single slug or comma-separated list) |
|
|
|
- Bookmarked books using the query parameter 'is_bookmark=true' |
|
|
|
|
|
|
|
You can also search for books by title, summary, publisher, or isbn using the query parameter 'search'. |
|
|
|
|
|
|
|
You can sort books by: |
|
|
|
- created_at, -created_at |
|
|
|
- view_count, -view_count |
|
|
|
- download_count, -download_count |
|
|
|
- title, -title |
|
|
|
- pin, -pin, -pin,-created_at |
|
|
|
|
|
|
|
Note: To get downloaded books, use the separate endpoint /books/downloaded/ |
|
|
|
- Collection ID |
|
|
|
- Category slug(s) |
|
|
|
- Author slug |
|
|
|
- Bookmarked books |
|
|
|
|
|
|
|
You can search for books by title, summary, publisher, or isbn. |
|
|
|
""", |
|
|
|
operation_summary="List Books", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
manual_parameters=[collection_id_param, category_param, is_bookmark_param, search_param, sort_param], |
|
|
|
manual_parameters=[collection_id_param, category_param, author_param, is_bookmark_param, search_param, sort_param], |
|
|
|
responses={ |
|
|
|
200: books_response, |
|
|
|
401: "Authentication credentials were not provided or are invalid.", |
|
|
|
@ -237,9 +219,6 @@ category_list_swagger = swagger_auto_schema( |
|
|
|
operation_id="list_categories", |
|
|
|
operation_description=""" |
|
|
|
Retrieve a list of book categories. |
|
|
|
|
|
|
|
This endpoint returns a paginated list of book categories. Each category includes its |
|
|
|
title, slug, status, books count, and timestamps. |
|
|
|
""", |
|
|
|
operation_summary="List Book Categories", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
@ -254,9 +233,6 @@ pinned_collection_list_swagger = swagger_auto_schema( |
|
|
|
operation_id="list_pinned_collections", |
|
|
|
operation_description=""" |
|
|
|
Retrieve a list of pinned book collections with their top book covers. |
|
|
|
|
|
|
|
This endpoint returns a list of pinned book collections. Each collection includes its |
|
|
|
title and the covers of its top books by view count. |
|
|
|
""", |
|
|
|
operation_summary="List Pinned Book Collections", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
@ -271,12 +247,6 @@ middle_collection_list_swagger = swagger_auto_schema( |
|
|
|
operation_id="list_middle_collections", |
|
|
|
operation_description=""" |
|
|
|
Retrieve a list of middle section book collections with their books. |
|
|
|
|
|
|
|
This endpoint returns a list of middle section book collections. Each collection includes its |
|
|
|
title, slug, summary, status, order, and a list of books in the collection. |
|
|
|
|
|
|
|
Each book in the collection includes its id, title, slug, summary, thumbnail, author, |
|
|
|
view count, download count, and file type. |
|
|
|
""", |
|
|
|
operation_summary="List Middle Section Book Collections", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
@ -285,4 +255,55 @@ middle_collection_list_swagger = swagger_auto_schema( |
|
|
|
401: "Authentication credentials were not provided or are invalid.", |
|
|
|
500: "Internal server error occurred." |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
author_list_swagger = swagger_auto_schema( |
|
|
|
operation_id="list_library_authors", |
|
|
|
operation_description=""" |
|
|
|
Retrieve a paginated list of library authors. |
|
|
|
|
|
|
|
Each author includes thumbnail, full name, and number of active books. |
|
|
|
""", |
|
|
|
operation_summary="List Authors", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
responses={ |
|
|
|
200: authors_response, |
|
|
|
401: "Authentication credentials were not provided or are invalid.", |
|
|
|
500: "Internal server error occurred." |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
author_detail_swagger = swagger_auto_schema( |
|
|
|
operation_id="get_author_detail", |
|
|
|
operation_description=""" |
|
|
|
Retrieve detailed information about a specific author. |
|
|
|
|
|
|
|
This endpoint returns full name, birth date, death date, thumbnail, and books count. |
|
|
|
""", |
|
|
|
operation_summary="Get Author Detail", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
responses={ |
|
|
|
200: author_detail_response, |
|
|
|
401: "Authentication credentials were not provided or are invalid.", |
|
|
|
404: "The specified author does not exist.", |
|
|
|
500: "Internal server error occurred." |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
author_books_swagger = swagger_auto_schema( |
|
|
|
operation_id="list_author_books", |
|
|
|
operation_description=""" |
|
|
|
Retrieve a paginated list of books for a specific author. |
|
|
|
|
|
|
|
The author is identified by slug in the URL path. |
|
|
|
""", |
|
|
|
operation_summary="List Author Books", |
|
|
|
tags=["Dobodbi - Library"], |
|
|
|
manual_parameters=[is_bookmark_param, search_param, sort_param], |
|
|
|
responses={ |
|
|
|
200: books_response, |
|
|
|
401: "Authentication credentials were not provided or are invalid.", |
|
|
|
404: "The specified author does not exist.", |
|
|
|
500: "Internal server error occurred." |
|
|
|
} |
|
|
|
) |