diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppAuthorController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppAuthorController.java index 07523e5bc..b4e1e29c3 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppAuthorController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppAuthorController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.app.dto.AppAuthorDetail; import org.booklore.app.dto.AppAuthorSummary; import org.booklore.app.dto.AppPageResponse; @@ -11,10 +13,16 @@ import org.springframework.web.bind.annotation.*; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/authors") +@Tag(name = "App Authors", description = "Endpoints for browsing authors in the app experience") public class AppAuthorController { private final AppAuthorService mobileAuthorService; + @Operation( + summary = "List app authors", + description = "Retrieve paginated authors for the app with optional filtering and sorting.", + operationId = "appGetAuthors" + ) @GetMapping public ResponseEntity> getAuthors( @RequestParam(required = false, defaultValue = "0") Integer page, @@ -28,6 +36,11 @@ public class AppAuthorController { return ResponseEntity.ok(mobileAuthorService.getAuthors(page, size, sort, dir, libraryId, search, hasPhoto)); } + @Operation( + summary = "Get app author details", + description = "Retrieve detailed app-facing information for a single author.", + operationId = "appGetAuthorDetail" + ) @GetMapping("/{authorId}") public ResponseEntity getAuthorDetail( @PathVariable Long authorId) { diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppBookController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppBookController.java index 0b3c04061..35b9014ee 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppBookController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppBookController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.app.dto.*; import org.booklore.app.service.AppBookService; import org.booklore.model.enums.BookFileType; @@ -14,10 +16,16 @@ import java.util.List; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/books") +@Tag(name = "App Books", description = "Endpoints for browsing and updating books in the app experience") public class AppBookController { private final AppBookService mobileBookService; + @Operation( + summary = "List app books", + description = "Retrieve paginated books for the app with optional filtering and sorting.", + operationId = "appGetBooks" + ) @GetMapping public ResponseEntity> getBooks( @RequestParam(required = false, defaultValue = "0") Integer page, @@ -39,6 +47,11 @@ public class AppBookController { fileType, minRating, maxRating, authors, language)); } + @Operation( + summary = "Get app book details", + description = "Retrieve detailed app-facing information for a single book.", + operationId = "appGetBookDetail" + ) @GetMapping("/{bookId}") public ResponseEntity getBookDetail( @PathVariable Long bookId) { @@ -46,6 +59,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.getBookDetail(bookId)); } + @Operation( + summary = "Search app books", + description = "Search books in the app catalog using a free-text query.", + operationId = "appSearchBooks" + ) @GetMapping("/search") public ResponseEntity> searchBooks( @RequestParam String q, @@ -55,6 +73,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.searchBooks(q, page, size)); } + @Operation( + summary = "Get continue reading books", + description = "Retrieve books currently in progress for reading in the app.", + operationId = "appGetContinueReading" + ) @GetMapping("/continue-reading") public ResponseEntity> getContinueReading( @RequestParam(required = false, defaultValue = "10") Integer limit) { @@ -62,6 +85,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.getContinueReading(limit)); } + @Operation( + summary = "Get continue listening books", + description = "Retrieve audiobooks currently in progress for listening in the app.", + operationId = "appGetContinueListening" + ) @GetMapping("/continue-listening") public ResponseEntity> getContinueListening( @RequestParam(required = false, defaultValue = "10") Integer limit) { @@ -69,6 +97,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.getContinueListening(limit)); } + @Operation( + summary = "Get recently added books", + description = "Retrieve recently added books for the app home experience.", + operationId = "appGetRecentlyAdded" + ) @GetMapping("/recently-added") public ResponseEntity> getRecentlyAdded( @RequestParam(required = false, defaultValue = "10") Integer limit) { @@ -76,6 +109,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.getRecentlyAdded(limit)); } + @Operation( + summary = "Get recently scanned books", + description = "Retrieve recently scanned books for the app home experience.", + operationId = "appGetRecentlyScanned" + ) @GetMapping("/recently-scanned") public ResponseEntity> getRecentlyScanned( @RequestParam(required = false, defaultValue = "10") Integer limit) { @@ -83,6 +121,11 @@ public class AppBookController { return ResponseEntity.ok(mobileBookService.getRecentlyScanned(limit)); } + @Operation( + summary = "Update app book read status", + description = "Update the read status of a book from the app interface.", + operationId = "appUpdateStatus" + ) @PutMapping("/{bookId}/status") public ResponseEntity updateStatus( @PathVariable Long bookId, @@ -92,6 +135,11 @@ public class AppBookController { return ResponseEntity.ok().build(); } + @Operation( + summary = "Update app book rating", + description = "Update the personal rating of a book from the app interface.", + operationId = "appUpdateRating" + ) @PutMapping("/{bookId}/rating") public ResponseEntity updateRating( @PathVariable Long bookId, @@ -101,6 +149,11 @@ public class AppBookController { return ResponseEntity.ok().build(); } + @Operation( + summary = "Get random app books", + description = "Retrieve a paginated random selection of books for discovery in the app.", + operationId = "appGetRandomBooks" + ) @GetMapping("/random") public ResponseEntity> getRandomBooks( @RequestParam(required = false, defaultValue = "0") Integer page, diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppFilterController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppFilterController.java index f8a231a1f..274d23bab 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppFilterController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppFilterController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.app.dto.AppFilterOptions; import org.booklore.app.service.AppBookService; import lombok.AllArgsConstructor; @@ -12,10 +14,16 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app") +@Tag(name = "App Filters", description = "Endpoints for retrieving app filter options") public class AppFilterController { private final AppBookService mobileBookService; + @Operation( + summary = "Get app filter options", + description = "Retrieve available filter values for app book browsing.", + operationId = "appGetFilterOptions" + ) @GetMapping("/filter-options") public ResponseEntity getFilterOptions( @RequestParam(required = false) Long libraryId, diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppLibraryController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppLibraryController.java index 4a24cab62..bb6dc5aff 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppLibraryController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppLibraryController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.config.security.service.AuthenticationService; import org.booklore.app.dto.AppLibrarySummary; import org.booklore.app.mapper.AppBookMapper; @@ -20,6 +22,7 @@ import java.util.stream.Collectors; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/libraries") +@Tag(name = "App Libraries", description = "Endpoints for retrieving libraries in the app experience") public class AppLibraryController { private final AuthenticationService authenticationService; @@ -27,6 +30,11 @@ public class AppLibraryController { private final BookRepository bookRepository; private final AppBookMapper mobileBookMapper; + @Operation( + summary = "List app libraries", + description = "Retrieve libraries visible to the current app user, including per-library book counts.", + operationId = "appGetLibraries" + ) @GetMapping public ResponseEntity> getLibraries() { BookLoreUser user = authenticationService.getAuthenticatedUser(); diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppNotebookController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppNotebookController.java index 6c8887780..dc199fcd2 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppNotebookController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppNotebookController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.app.dto.AppNotebookBookSummary; import org.booklore.app.dto.AppNotebookEntry; import org.booklore.app.dto.AppNotebookUpdateRequest; @@ -15,10 +17,16 @@ import java.util.Set; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/notebook") +@Tag(name = "App Notebook", description = "Endpoints for notebook browsing and editing in the app experience") public class AppNotebookController { private final AppNotebookService mobileNotebookService; + @Operation( + summary = "List notebook books", + description = "Retrieve paginated books that contain notebook entries in the app.", + operationId = "appGetBooksWithAnnotations" + ) @GetMapping("/books") public ResponseEntity> getBooksWithAnnotations( @RequestParam(required = false, defaultValue = "0") Integer page, @@ -28,6 +36,11 @@ public class AppNotebookController { return ResponseEntity.ok(mobileNotebookService.getBooksWithAnnotations(page, size, search)); } + @Operation( + summary = "List notebook entries for book", + description = "Retrieve paginated notebook entries for a specific book in the app.", + operationId = "appGetEntriesForBook" + ) @GetMapping("/books/{bookId}/entries") public ResponseEntity> getEntriesForBook( @PathVariable Long bookId, @@ -40,6 +53,11 @@ public class AppNotebookController { return ResponseEntity.ok(mobileNotebookService.getEntriesForBook(bookId, page, size, types, search, sort)); } + @Operation( + summary = "Update notebook entry", + description = "Update an existing notebook entry in the app.", + operationId = "appUpdateEntry" + ) @PutMapping("/entries/{entryId}") public ResponseEntity updateEntry( @PathVariable Long entryId, @@ -49,6 +67,11 @@ public class AppNotebookController { return ResponseEntity.ok(mobileNotebookService.updateEntry(entryId, type, request)); } + @Operation( + summary = "Delete notebook entry", + description = "Delete an existing notebook entry in the app.", + operationId = "appDeleteEntry" + ) @DeleteMapping("/entries/{entryId}") public ResponseEntity deleteEntry( @PathVariable Long entryId, diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppSeriesController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppSeriesController.java index 6b47a9c56..14c676bfb 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppSeriesController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppSeriesController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.booklore.app.dto.AppBookSummary; import org.booklore.app.dto.AppPageResponse; @@ -11,10 +13,16 @@ import org.springframework.web.bind.annotation.*; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/series") +@Tag(name = "App Series", description = "Endpoints for browsing series in the app experience") public class AppSeriesController { private final AppSeriesService mobileSeriesService; + @Operation( + summary = "List app series", + description = "Retrieve paginated series for the app with optional filtering and sorting.", + operationId = "appGetSeries" + ) @GetMapping public ResponseEntity> getSeries( @RequestParam(required = false, defaultValue = "0") Integer page, @@ -33,6 +41,11 @@ public class AppSeriesController { return ResponseEntity.ok(response); } + @Operation( + summary = "List books in app series", + description = "Retrieve paginated books belonging to a specific series for the app.", + operationId = "appGetSeriesBooks" + ) @GetMapping("/{seriesName}/books") public ResponseEntity> getSeriesBooks( @PathVariable String seriesName, diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppShelfController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppShelfController.java index b12ac6d5b..e1c14272e 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppShelfController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppShelfController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.config.security.service.AuthenticationService; import org.booklore.app.dto.AppBookSummary; import org.booklore.app.dto.AppMagicShelfSummary; @@ -25,6 +27,7 @@ import java.util.stream.Collectors; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/shelves") +@Tag(name = "App Shelves", description = "Endpoints for browsing shelves and magic shelves in the app experience") public class AppShelfController { private final AuthenticationService authenticationService; @@ -33,6 +36,11 @@ public class AppShelfController { private final AppBookMapper mobileBookMapper; private final AppBookService mobileBookService; + @Operation( + summary = "List app shelves", + description = "Retrieve all regular shelves visible to the current app user.", + operationId = "appGetShelves" + ) @GetMapping public ResponseEntity> getShelves() { BookLoreUser user = authenticationService.getAuthenticatedUser(); @@ -47,6 +55,11 @@ public class AppShelfController { return ResponseEntity.ok(summaries); } + @Operation( + summary = "List app magic shelves", + description = "Retrieve all magic shelves visible to the current app user.", + operationId = "appGetMagicShelves" + ) @GetMapping("/magic") public ResponseEntity> getMagicShelves() { BookLoreUser user = authenticationService.getAuthenticatedUser(); @@ -80,6 +93,11 @@ public class AppShelfController { return ResponseEntity.ok(summaries); } + @Operation( + summary = "List books in app magic shelf", + description = "Retrieve paginated books contained in a specific magic shelf for the app.", + operationId = "appGetBooksByMagicShelf" + ) @GetMapping("/magic/{magicShelfId}/books") public ResponseEntity> getBooksByMagicShelf( @PathVariable Long magicShelfId, diff --git a/booklore-api/src/main/java/org/booklore/app/controller/AppUserController.java b/booklore-api/src/main/java/org/booklore/app/controller/AppUserController.java index fc54d3f06..3e23ee46d 100644 --- a/booklore-api/src/main/java/org/booklore/app/controller/AppUserController.java +++ b/booklore-api/src/main/java/org/booklore/app/controller/AppUserController.java @@ -1,5 +1,7 @@ package org.booklore.app.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.config.security.service.AuthenticationService; import org.booklore.app.dto.AppUserInfo; import org.booklore.model.dto.BookLoreUser; @@ -13,11 +15,17 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor @RestController @RequestMapping("/api/v1/app/users") +@Tag(name = "App Users", description = "Endpoints for retrieving app user capabilities and profile information") public class AppUserController { private final AuthenticationService authenticationService; private final AppSettingService appSettingService; + @Operation( + summary = "Get current app user", + description = "Retrieve current user flags and capability information used by the app experience.", + operationId = "appGetCurrentUser" + ) @GetMapping("/me") public ResponseEntity getCurrentUser() { BookLoreUser user = authenticationService.getAuthenticatedUser(); diff --git a/booklore-api/src/main/java/org/booklore/controller/AdditionalFileController.java b/booklore-api/src/main/java/org/booklore/controller/AdditionalFileController.java index e9801ca95..b41a3b89b 100644 --- a/booklore-api/src/main/java/org/booklore/controller/AdditionalFileController.java +++ b/booklore-api/src/main/java/org/booklore/controller/AdditionalFileController.java @@ -1,5 +1,7 @@ package org.booklore.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.config.security.annotation.CheckBookAccess; import org.booklore.model.dto.BookFile; import org.booklore.model.dto.request.DetachBookFileRequest; @@ -21,12 +23,18 @@ import java.util.List; @RequestMapping("/api/v1/books/{bookId}/files") @RestController @AllArgsConstructor +@Tag(name = "Book Files", description = "Endpoints for managing additional files attached to books") public class AdditionalFileController { private final AdditionalFileService additionalFileService; private final FileUploadService fileUploadService; private final BookFileDetachmentService bookFileDetachmentService; + @Operation( + summary = "List additional book files", + description = "Retrieve additional files for a specific book.", + operationId = "additionalFileGetAdditionalFiles" + ) @GetMapping @CheckBookAccess(bookIdParam = "bookId") public ResponseEntity> getAdditionalFiles(@PathVariable Long bookId) { @@ -34,6 +42,11 @@ public class AdditionalFileController { return ResponseEntity.ok(files); } + @Operation( + summary = "List additional files by type", + description = "Retrieve additional files for a specific book filtered by whether they are primary book files.", + operationId = "additionalFileGetFilesByIsBook" + ) @GetMapping(params = "isBook") @CheckBookAccess(bookIdParam = "bookId") public ResponseEntity> getFilesByIsBook( @@ -43,6 +56,11 @@ public class AdditionalFileController { return ResponseEntity.ok(files); } + @Operation( + summary = "Upload additional book file", + description = "Upload and attach a new additional file to a specific book.", + operationId = "additionalFileUploadAdditionalFile" + ) @PostMapping(consumes = "multipart/form-data") @CheckBookAccess(bookIdParam = "bookId") @PreAuthorize("@securityUtil.canUpload() or @securityUtil.isAdmin()") @@ -56,6 +74,11 @@ public class AdditionalFileController { return ResponseEntity.ok(additionalFile); } + @Operation( + summary = "Download additional book file", + description = "Download a specific additional file attached to a book.", + operationId = "additionalFileDownloadAdditionalFile" + ) @GetMapping("/{fileId}/download") @CheckBookAccess(bookIdParam = "bookId") public ResponseEntity downloadAdditionalFile( @@ -64,6 +87,11 @@ public class AdditionalFileController { return additionalFileService.downloadAdditionalFile(fileId); } + @Operation( + summary = "Delete additional book file", + description = "Delete a specific additional file attached to a book.", + operationId = "additionalFileDeleteAdditionalFile" + ) @DeleteMapping("/{fileId}") @CheckBookAccess(bookIdParam = "bookId") @PreAuthorize("@securityUtil.canDeleteBook() or @securityUtil.isAdmin()") @@ -74,6 +102,11 @@ public class AdditionalFileController { return ResponseEntity.noContent().build(); } + @Operation( + summary = "Detach additional book file", + description = "Detach a specific additional file from a book and optionally copy metadata.", + operationId = "additionalFileDetachFile" + ) @PostMapping("/{fileId}/detach") @CheckBookAccess(bookIdParam = "bookId") @PreAuthorize("@securityUtil.canManageLibrary() or @securityUtil.isAdmin()") diff --git a/booklore-api/src/main/java/org/booklore/controller/LogoutController.java b/booklore-api/src/main/java/org/booklore/controller/LogoutController.java index c6bc66694..2aa1e574f 100644 --- a/booklore-api/src/main/java/org/booklore/controller/LogoutController.java +++ b/booklore-api/src/main/java/org/booklore/controller/LogoutController.java @@ -1,5 +1,7 @@ package org.booklore.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.booklore.config.security.service.LogoutService; import org.booklore.model.dto.request.LogoutRequest; @@ -15,10 +17,16 @@ import org.springframework.web.bind.annotation.RestController; @AllArgsConstructor @RestController @RequestMapping("/api/v1/auth") +@Tag(name = "Authentication", description = "Endpoints for user authentication, registration, and token management") public class LogoutController { private final LogoutService logoutService; + @Operation( + summary = "Logout user", + description = "Logout the current user and invalidate refresh token state when provided.", + operationId = "logout" + ) @PostMapping("/logout") public ResponseEntity logout(Authentication auth, @RequestBody(required = false) LogoutRequest request, diff --git a/booklore-api/src/main/java/org/booklore/controller/OidcAuthController.java b/booklore-api/src/main/java/org/booklore/controller/OidcAuthController.java index b9db22e11..7ec8e8ac3 100644 --- a/booklore-api/src/main/java/org/booklore/controller/OidcAuthController.java +++ b/booklore-api/src/main/java/org/booklore/controller/OidcAuthController.java @@ -1,5 +1,7 @@ package org.booklore.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import lombok.AllArgsConstructor; @@ -26,6 +28,7 @@ import java.util.Map; @AllArgsConstructor @RestController @RequestMapping("/api/v1/auth/oidc") +@Tag(name = "OIDC Authentication", description = "Endpoints for OIDC state generation, callbacks, and logout flows") public class OidcAuthController { private final OidcAuthService oidcAuthService; @@ -33,11 +36,21 @@ public class OidcAuthController { private final OidcStateService oidcStateService; private final AuditService auditService; + @Operation( + summary = "Generate OIDC state", + description = "Generate a one-time state value for initiating an OIDC authentication flow.", + operationId = "oidcGenerateState" + ) @GetMapping("/state") public ResponseEntity> generateState() { return ResponseEntity.ok(Map.of("state", oidcStateService.generateState())); } + @Operation( + summary = "Handle OIDC callback", + description = "Process the OIDC callback payload and exchange authorization code for tokens.", + operationId = "oidcHandleCallback" + ) @PostMapping("/callback") public ResponseEntity> handleCallback( @RequestBody @Valid OidcCallbackRequest request, @@ -58,6 +71,11 @@ public class OidcAuthController { } } + @Operation( + summary = "Handle OIDC redirect callback", + description = "Handle redirect-based OIDC callback and redirect back to the app with token information.", + operationId = "oidcHandleRedirect" + ) @GetMapping("/redirect") public ResponseEntity handleRedirect( @RequestParam("code") String code, @@ -104,6 +122,11 @@ public class OidcAuthController { } } + @Operation( + summary = "Handle OIDC mobile callback", + description = "Process mobile OIDC callback parameters and exchange authorization code for tokens.", + operationId = "oidcHandleMobileCallback" + ) @PostMapping("/mobile/callback") public ResponseEntity> handleMobileCallback( @RequestParam("code") String code, @@ -122,6 +145,11 @@ public class OidcAuthController { } } + @Operation( + summary = "Handle OIDC backchannel logout", + description = "Process OIDC backchannel logout token and invalidate matching session state.", + operationId = "oidcBackchannelLogout" + ) @PostMapping(value = "/backchannel-logout", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public ResponseEntity backchannelLogout(@RequestParam("logout_token") String logoutToken) { try { diff --git a/booklore-api/src/main/java/org/booklore/controller/OidcGroupMappingController.java b/booklore-api/src/main/java/org/booklore/controller/OidcGroupMappingController.java index e727a7d8a..9e529bad7 100644 --- a/booklore-api/src/main/java/org/booklore/controller/OidcGroupMappingController.java +++ b/booklore-api/src/main/java/org/booklore/controller/OidcGroupMappingController.java @@ -1,5 +1,7 @@ package org.booklore.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.booklore.model.dto.OidcGroupMapping; import org.booklore.service.oidc.OidcGroupMappingService; @@ -13,25 +15,46 @@ import java.util.List; @RequestMapping("/api/v1/admin/oidc-group-mappings") @PreAuthorize("@securityUtil.isAdmin()") @AllArgsConstructor +@Tag(name = "OIDC Group Mappings", description = "Endpoints for managing OIDC group-to-role mappings") public class OidcGroupMappingController { private final OidcGroupMappingService oidcGroupMappingService; + @Operation( + summary = "List OIDC group mappings", + description = "Retrieve all configured OIDC group mappings.", + operationId = "oidcGroupMappingGetAll" + ) @GetMapping public List getAll() { return oidcGroupMappingService.getAll(); } + @Operation( + summary = "Create OIDC group mapping", + description = "Create a new OIDC group mapping.", + operationId = "oidcGroupMappingCreate" + ) @PostMapping public OidcGroupMapping create(@Valid @RequestBody OidcGroupMapping mapping) { return oidcGroupMappingService.create(mapping); } + @Operation( + summary = "Update OIDC group mapping", + description = "Update an existing OIDC group mapping by ID.", + operationId = "oidcGroupMappingUpdate" + ) @PutMapping("/{id}") public OidcGroupMapping update(@PathVariable Long id, @Valid @RequestBody OidcGroupMapping mapping) { return oidcGroupMappingService.update(id, mapping); } + @Operation( + summary = "Delete OIDC group mapping", + description = "Delete an OIDC group mapping by ID.", + operationId = "oidcGroupMappingDelete" + ) @DeleteMapping("/{id}") public void delete(@PathVariable Long id) { oidcGroupMappingService.delete(id); diff --git a/booklore-api/src/main/java/org/booklore/controller/ReadingSessionController.java b/booklore-api/src/main/java/org/booklore/controller/ReadingSessionController.java index a51f54f76..9d8c37665 100644 --- a/booklore-api/src/main/java/org/booklore/controller/ReadingSessionController.java +++ b/booklore-api/src/main/java/org/booklore/controller/ReadingSessionController.java @@ -6,6 +6,7 @@ import org.booklore.service.ReadingSessionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; @@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.*; @RestController @AllArgsConstructor @RequestMapping("/api/v1/reading-sessions") +@Tag(name = "Reading Sessions", description = "Endpoints for recording and retrieving user reading sessions") public class ReadingSessionController { private final ReadingSessionService readingSessionService; diff --git a/booklore-api/src/main/java/org/booklore/controller/TaskController.java b/booklore-api/src/main/java/org/booklore/controller/TaskController.java index c4429a5d0..875aedfe6 100644 --- a/booklore-api/src/main/java/org/booklore/controller/TaskController.java +++ b/booklore-api/src/main/java/org/booklore/controller/TaskController.java @@ -1,5 +1,7 @@ package org.booklore.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.booklore.model.dto.TaskInfo; import org.booklore.model.dto.request.TaskCreateRequest; import org.booklore.model.dto.request.TaskCronConfigRequest; @@ -23,12 +25,18 @@ import java.util.List; @AllArgsConstructor @RestController @RequestMapping("/api/v1/tasks") +@Tag(name = "Tasks", description = "Endpoints for listing, starting, canceling, and scheduling background tasks") public class TaskController { private final TaskService service; private final TaskHistoryService taskHistoryService; private final TaskCronService taskCronService; + @Operation( + summary = "List available tasks", + description = "Retrieve all task types available to the current user.", + operationId = "taskGetAvailableTasks" + ) @GetMapping @PreAuthorize("@securityUtil.canAccessTaskManager() or @securityUtil.isAdmin()") public ResponseEntity> getAvailableTasks() { @@ -36,6 +44,11 @@ public class TaskController { return ResponseEntity.ok(taskInfos); } + @Operation( + summary = "Start task", + description = "Start a task immediately with the provided task request payload.", + operationId = "taskStartTask" + ) @PostMapping("/start") @PreAuthorize("@securityUtil.canAccessTaskManager() or @securityUtil.isAdmin()") public ResponseEntity startTask(@RequestBody TaskCreateRequest request) { @@ -46,6 +59,11 @@ public class TaskController { return ResponseEntity.ok(response); } + @Operation( + summary = "Cancel task", + description = "Cancel an in-progress task by task ID.", + operationId = "taskCancelTask" + ) @DeleteMapping("/{taskId}/cancel") @PreAuthorize("@securityUtil.canAccessTaskManager() or @securityUtil.isAdmin()") public ResponseEntity cancelTask(@PathVariable String taskId) { @@ -53,6 +71,11 @@ public class TaskController { return ResponseEntity.ok(response); } + @Operation( + summary = "Get latest tasks by type", + description = "Retrieve the latest task execution entry for each task type.", + operationId = "taskGetLatestTasksForEachType" + ) @GetMapping("/last") @PreAuthorize("@securityUtil.canAccessTaskManager() or @securityUtil.isAdmin()") public ResponseEntity getLatestTasksForEachType() { @@ -60,6 +83,11 @@ public class TaskController { return ResponseEntity.ok(response); } + @Operation( + summary = "Update task cron configuration", + description = "Patch cron schedule configuration for a task type and reschedule execution.", + operationId = "taskPatchCronConfig" + ) @PatchMapping("/{taskType}/cron") @PreAuthorize("@securityUtil.canAccessTaskManager() or @securityUtil.isAdmin()") public ResponseEntity patchCronConfig(@PathVariable TaskType taskType, @RequestBody TaskCronConfigRequest request) { diff --git a/booklore-api/src/main/java/org/booklore/controller/UserStatsController.java b/booklore-api/src/main/java/org/booklore/controller/UserStatsController.java index da3ff1d6b..4d69b382d 100644 --- a/booklore-api/src/main/java/org/booklore/controller/UserStatsController.java +++ b/booklore-api/src/main/java/org/booklore/controller/UserStatsController.java @@ -5,6 +5,7 @@ import org.booklore.service.ReadingSessionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -15,6 +16,7 @@ import java.util.List; @RestController @AllArgsConstructor @RequestMapping("/api/v1/user-stats") +@Tag(name = "User Stats", description = "Endpoints for reading and listening analytics derived from user sessions") public class UserStatsController { private final ReadingSessionService readingSessionService; @@ -281,6 +283,11 @@ public class UserStatsController { return ResponseEntity.ok(readingSessionService.getListeningFinishFunnel()); } + @Operation( + summary = "Get listening peak hours", + description = "Returns listening activity distribution by hour of day. Can be filtered by year and/or month.", + operationId = "getListeningPeakHours" + ) @GetMapping("/listening/peak-hours") @PreAuthorize("@securityUtil.canAccessUserStats() or @securityUtil.isAdmin()") public ResponseEntity> getListeningPeakHours( @@ -289,24 +296,44 @@ public class UserStatsController { return ResponseEntity.ok(readingSessionService.getListeningPeakHours(year, month)); } + @Operation( + summary = "Get listening genre statistics", + description = "Returns listening statistics grouped by audiobook genres/categories.", + operationId = "getListeningGenreStatistics" + ) @GetMapping("/listening/genres") @PreAuthorize("@securityUtil.canAccessUserStats() or @securityUtil.isAdmin()") public ResponseEntity> getListeningGenreStatistics() { return ResponseEntity.ok(readingSessionService.getListeningGenreStatistics()); } + @Operation( + summary = "Get listening author statistics", + description = "Returns listening statistics grouped by audiobook authors.", + operationId = "getListeningAuthorStats" + ) @GetMapping("/listening/authors") @PreAuthorize("@securityUtil.canAccessUserStats() or @securityUtil.isAdmin()") public ResponseEntity> getListeningAuthorStats() { return ResponseEntity.ok(readingSessionService.getListeningAuthorStats()); } + @Operation( + summary = "Get listening session scatter data", + description = "Returns individual listening session points for scatter plot visualizations.", + operationId = "getListeningSessionScatter" + ) @GetMapping("/listening/session-scatter") @PreAuthorize("@securityUtil.canAccessUserStats() or @securityUtil.isAdmin()") public ResponseEntity> getListeningSessionScatter() { return ResponseEntity.ok(readingSessionService.getListeningSessionScatter()); } + @Operation( + summary = "Get longest listened audiobooks", + description = "Returns longest audiobooks ranked by listening duration.", + operationId = "getListeningLongestBooks" + ) @GetMapping("/listening/longest-books") @PreAuthorize("@securityUtil.canAccessUserStats() or @securityUtil.isAdmin()") public ResponseEntity> getListeningLongestBooks() { diff --git a/dev.docker-compose.yml b/dev.docker-compose.yml index ca41b9f11..d4495025e 100644 --- a/dev.docker-compose.yml +++ b/dev.docker-compose.yml @@ -16,6 +16,7 @@ services: - DATABASE_PASSWORD=grimmory - REMOTE_DEBUG_ENABLED=true - ALLOWED_ORIGINS=http://localhost:4200 + - API_DOCS_ENABLED=true - JAVA_TOOL_OPTIONS=-XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact -XX:+UseCompactObjectHeaders -XX:MaxRAMPercentage=60.0 -XX:InitialRAMPercentage=8.0 -XX:+ExitOnOutOfMemoryError -XX:MaxMetaspaceSize=192m -XX:ReservedCodeCacheSize=64m -Xss512k -XX:CICompilerCount=2 -XX:+UnlockExperimentalVMOptions -XX:ShenandoahUncommitDelay=5000 -XX:ShenandoahGuaranteedGCInterval=30000 stdin_open: true tty: true