openapi: 3.1.0 info: title: Api version: 0.1.0 description: Shia Digital Library API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: books description: Book operations - name: authors description: Author operations - name: subjects description: Subject operations - name: Storage description: Object storage upload and serving endpoints. paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /books: get: operationId: listBooks tags: [books] summary: List all books with optional search/filter parameters: - name: query in: query schema: type: string description: Search by title, author, or keyword - name: subject in: query schema: type: string description: Filter by subject - name: author_id in: query schema: type: ["integer", "null"] description: Filter by author ID - name: page in: query schema: type: integer default: 1 - name: limit in: query schema: type: integer default: 20 responses: "200": description: List of books content: application/json: schema: $ref: "#/components/schemas/BookList" post: operationId: createBook tags: [books] summary: Add a new book requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BookInput" responses: "201": description: Created book content: application/json: schema: $ref: "#/components/schemas/Book" /books/{id}: get: operationId: getBook tags: [books] summary: Get a single book by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Book details content: application/json: schema: $ref: "#/components/schemas/Book" "404": description: Not found patch: operationId: updateBook tags: [books] summary: Update a book parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/BookUpdate" responses: "200": description: Updated book content: application/json: schema: $ref: "#/components/schemas/Book" delete: operationId: deleteBook tags: [books] summary: Delete a book parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /books/stats: get: operationId: getBooksStats tags: [books] summary: Get library statistics (total books, authors, subjects) responses: "200": description: Library stats content: application/json: schema: $ref: "#/components/schemas/LibraryStats" /books/recent: get: operationId: getRecentBooks tags: [books] summary: Get recently added books parameters: - name: limit in: query schema: type: integer default: 8 responses: "200": description: Recent books content: application/json: schema: type: array items: $ref: "#/components/schemas/Book" /authors: get: operationId: listAuthors tags: [authors] summary: List all authors responses: "200": description: List of authors content: application/json: schema: type: array items: $ref: "#/components/schemas/Author" post: operationId: createAuthor tags: [authors] summary: Add a new author requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AuthorInput" responses: "201": description: Created author content: application/json: schema: $ref: "#/components/schemas/Author" /authors/{id}: get: operationId: getAuthor tags: [authors] summary: Get a single author by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Author details content: application/json: schema: $ref: "#/components/schemas/Author" "404": description: Not found patch: operationId: updateAuthor tags: [authors] summary: Update an author parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AuthorUpdate" responses: "200": description: Updated author content: application/json: schema: $ref: "#/components/schemas/Author" delete: operationId: deleteAuthor tags: [authors] summary: Delete an author parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /subjects: get: operationId: listSubjects tags: [subjects] summary: List all subjects with book counts responses: "200": description: List of subjects content: application/json: schema: type: array items: $ref: "#/components/schemas/Subject" /storage/uploads/request-url: post: tags: [Storage] operationId: requestUploadUrl summary: Request a presigned URL for file upload requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UploadUrlRequest' responses: '200': description: Presigned upload URL generated. content: application/json: schema: $ref: '#/components/schemas/UploadUrlResponse' '400': description: Missing or invalid required fields. content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' '500': description: Failed to generate upload URL. content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /storage/public-objects/{filePath}: get: tags: [Storage] operationId: getPublicObject summary: Serve a public asset parameters: - name: filePath in: path required: true schema: type: string responses: '200': description: Object content streamed. content: '*/*': schema: type: string format: binary '404': description: File not found. content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /storage/objects/{objectPath}: get: tags: [Storage] operationId: getStorageObject summary: Serve an object entity parameters: - name: objectPath in: path required: true schema: type: string responses: '200': description: Object content streamed. content: '*/*': schema: type: string format: binary '404': description: Object not found. content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' components: schemas: HealthStatus: type: object properties: status: type: string required: - status Book: type: object required: [id, title, author_id, subject, year, full_text] properties: id: type: integer title: type: string author_id: type: integer author_name: type: ["string", "null"] subject: type: string year: type: ["integer", "null"] keywords: type: ["string", "null"] full_text: type: string description: type: ["string", "null"] pdf_url: type: ["string", "null"] created_at: type: string BookList: type: object required: [books, total, page, limit] properties: books: type: array items: $ref: "#/components/schemas/Book" total: type: integer page: type: integer limit: type: integer BookInput: type: object required: [title, author_id, subject, full_text] properties: title: type: string author_id: type: integer subject: type: string year: type: ["integer", "null"] keywords: type: ["string", "null"] full_text: type: string description: type: ["string", "null"] pdf_url: type: ["string", "null"] BookUpdate: type: object properties: title: type: string author_id: type: integer subject: type: string year: type: ["integer", "null"] keywords: type: ["string", "null"] full_text: type: string description: type: ["string", "null"] pdf_url: type: ["string", "null"] Author: type: object required: [id, name] properties: id: type: integer name: type: string bio: type: ["string", "null"] birth_year: type: ["integer", "null"] death_year: type: ["integer", "null"] book_count: type: ["integer", "null"] AuthorInput: type: object required: [name] properties: name: type: string bio: type: ["string", "null"] birth_year: type: ["integer", "null"] death_year: type: ["integer", "null"] AuthorUpdate: type: object properties: name: type: string bio: type: ["string", "null"] birth_year: type: ["integer", "null"] death_year: type: ["integer", "null"] Subject: type: object required: [name, book_count] properties: name: type: string book_count: type: integer LibraryStats: type: object required: [total_books, total_authors, total_subjects] properties: total_books: type: integer total_authors: type: integer total_subjects: type: integer UploadUrlRequest: type: object required: [name, size, contentType] properties: name: type: string minLength: 1 size: type: integer minimum: 1 contentType: type: string minLength: 1 UploadUrlResponse: type: object required: [uploadURL, objectPath] properties: uploadURL: type: string format: uri objectPath: type: string metadata: $ref: '#/components/schemas/UploadUrlRequest' ErrorEnvelope: type: object required: [error] properties: error: type: string