2026-03-03 01:10:50 +01:00
|
|
|
pub mod cookie_auth;
|
2026-04-28 13:15:08 +02:00
|
|
|
pub mod deserializer;
|
2025-03-17 21:28:08 +01:00
|
|
|
pub mod handlers;
|
|
|
|
|
pub mod routes;
|
|
|
|
|
|
2026-02-08 13:40:23 +01:00
|
|
|
pub use routes::create_api_routes;
|
2026-05-11 00:22:03 +02:00
|
|
|
pub use routes::create_health_routes;
|
2026-02-14 01:29:34 +01:00
|
|
|
pub use routes::create_public_api_routes;
|
2026-03-29 18:49:10 +02:00
|
|
|
|
2026-05-28 00:20:21 +02:00
|
|
|
use utoipa::openapi::security::{Http, HttpAuthScheme, SecurityScheme};
|
2026-05-27 12:43:07 +02:00
|
|
|
use utoipa::{Modify, OpenApi};
|
2026-03-29 18:49:10 +02:00
|
|
|
|
2026-05-09 19:18:33 +02:00
|
|
|
use crate::application::dtos::contact_dto::{
|
|
|
|
|
AddressDto, ContactDto, ContactGroupDto, EmailDto, PhoneDto,
|
|
|
|
|
};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::application::dtos::favorites_dto::{
|
2026-05-31 00:26:21 +02:00
|
|
|
BatchFavoritesResult, BatchFavoritesStats, FavoriteItemDto, FavoritesResourceItemDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
};
|
|
|
|
|
use crate::application::dtos::file_dto::FileDto;
|
2026-04-01 12:25:10 +02:00
|
|
|
use crate::application::dtos::folder_dto::{
|
2026-05-31 00:26:21 +02:00
|
|
|
CreateFolderDto, FolderDto, FolderResourceItemDto, MoveFolderDto, RenameFolderDto,
|
2026-04-01 12:25:10 +02:00
|
|
|
};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::application::dtos::folder_listing_dto::FolderListingDto;
|
2026-05-24 01:05:13 +02:00
|
|
|
use crate::application::dtos::grant_dto::{
|
2026-05-31 00:26:21 +02:00
|
|
|
CreateGrantDto, GrantDto, OutgoingResourceItemDto, PermissionDto, ResourceContentDto,
|
|
|
|
|
ResourceDto, ResourceTypeDto, Role, SharedWithMeDto, SharedWithMeItemDto, SubjectDto,
|
|
|
|
|
SubjectTypeDto, UpdateRoleDto,
|
2026-05-24 01:05:13 +02:00
|
|
|
};
|
2026-04-27 22:59:18 +02:00
|
|
|
use crate::application::dtos::i18n_dto::{
|
|
|
|
|
LocaleDto, TranslationErrorDto, TranslationRequestDto, TranslationResponseDto,
|
|
|
|
|
};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::application::dtos::pagination::{PaginationDto, PaginationRequestDto};
|
2026-05-31 00:26:21 +02:00
|
|
|
use crate::application::dtos::recent_dto::{RecentItemDto, RecentResourceItemDto};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::application::dtos::search_dto::{
|
|
|
|
|
SearchCriteriaDto, SearchFileResultDto, SearchFolderResultDto, SearchResultsDto,
|
|
|
|
|
SearchSuggestionItem, SearchSuggestionsDto,
|
|
|
|
|
};
|
2026-05-28 19:56:31 +02:00
|
|
|
use crate::application::dtos::share_dto::{CreateShareDto, ShareDto, UpdateShareDto};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::application::dtos::trash_dto::{
|
2026-05-30 00:15:07 +02:00
|
|
|
DeletePermanentlyRequest, MoveToTrashRequest, RestoreFromTrashRequest, TrashResourceItemDto,
|
|
|
|
|
TrashResourcesDto, TrashedItemDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
};
|
|
|
|
|
use crate::application::dtos::user_dto::{
|
2026-05-28 00:20:21 +02:00
|
|
|
AuthResponseDto, ChangePasswordDto, LoginDto, OidcExchangeDto, OidcProviderInfoDto,
|
|
|
|
|
RefreshTokenDto, RegisterDto, SetupAdminDto, UserDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
};
|
2026-04-27 22:59:18 +02:00
|
|
|
use crate::application::ports::chunked_upload_ports::{
|
|
|
|
|
ChunkUploadResponseDto, CreateUploadResponseDto, UploadStatusResponseDto,
|
|
|
|
|
};
|
2026-05-27 12:43:07 +02:00
|
|
|
use crate::interfaces::api::handlers::auth_handler::SystemStatus;
|
2026-04-27 22:59:18 +02:00
|
|
|
use crate::interfaces::api::handlers::chunked_upload_handler::{
|
|
|
|
|
CompleteUploadResponse, CreateUploadRequest,
|
|
|
|
|
};
|
2026-05-09 19:18:33 +02:00
|
|
|
use crate::interfaces::api::handlers::contacts_handler::{
|
|
|
|
|
AddMemberRequest, AddressBookResponse, CreateAddressBookRequest, CreateContactRequest,
|
|
|
|
|
GroupNameRequest, UpdateAddressBookRequest, UpdateContactRequest,
|
|
|
|
|
};
|
2026-04-27 22:59:18 +02:00
|
|
|
use crate::interfaces::api::handlers::dedup_handler::{
|
|
|
|
|
DedupUploadResponse, HashCheckResponse, StatsResponse,
|
|
|
|
|
};
|
2026-03-29 18:49:10 +02:00
|
|
|
use crate::interfaces::api::handlers::file_handler::MoveFilePayload;
|
|
|
|
|
|
|
|
|
|
#[derive(OpenApi)]
|
|
|
|
|
#[openapi(
|
2026-05-28 00:20:21 +02:00
|
|
|
modifiers(&SecurityAddon),
|
2026-03-29 18:49:10 +02:00
|
|
|
paths(
|
2026-05-28 00:20:21 +02:00
|
|
|
// Auth handlers (public, protected, OIDC)
|
|
|
|
|
handlers::auth_handler::register,
|
|
|
|
|
handlers::auth_handler::login,
|
|
|
|
|
handlers::auth_handler::refresh_token,
|
|
|
|
|
handlers::auth_handler::get_current_user,
|
|
|
|
|
handlers::auth_handler::change_password,
|
|
|
|
|
handlers::auth_handler::logout,
|
|
|
|
|
handlers::auth_handler::setup_admin,
|
|
|
|
|
handlers::auth_handler::get_system_status,
|
|
|
|
|
handlers::auth_handler::oidc_providers,
|
|
|
|
|
handlers::auth_handler::oidc_authorize,
|
|
|
|
|
handlers::auth_handler::oidc_callback,
|
|
|
|
|
handlers::auth_handler::oidc_exchange,
|
2026-04-27 22:59:18 +02:00
|
|
|
// File handlers (free functions — see file_handler.rs for why)
|
|
|
|
|
handlers::file_handler::list_files_query,
|
|
|
|
|
handlers::file_handler::upload_file_with_thumbnails,
|
2026-06-11 13:54:32 +00:00
|
|
|
handlers::file_handler::create_file_by_hash,
|
2026-06-11 14:34:02 +00:00
|
|
|
handlers::delta_upload_handler::delta_negotiate,
|
|
|
|
|
handlers::delta_upload_handler::delta_upload_chunks,
|
|
|
|
|
handlers::delta_upload_handler::delta_commit,
|
2026-04-27 22:59:18 +02:00
|
|
|
handlers::file_handler::download_file,
|
|
|
|
|
handlers::file_handler::get_thumbnail,
|
|
|
|
|
handlers::file_handler::upload_thumbnail,
|
|
|
|
|
handlers::file_handler::get_file_metadata,
|
|
|
|
|
handlers::file_handler::delete_file,
|
|
|
|
|
handlers::file_handler::rename_file,
|
|
|
|
|
handlers::file_handler::move_file_simple,
|
|
|
|
|
// Folder handlers (free functions — see folder_handler.rs for why)
|
|
|
|
|
handlers::folder_handler::create_folder,
|
|
|
|
|
handlers::folder_handler::get_folder,
|
|
|
|
|
handlers::folder_handler::list_root_folders,
|
|
|
|
|
handlers::folder_handler::list_folder_contents,
|
|
|
|
|
handlers::folder_handler::list_root_folders_paginated,
|
|
|
|
|
handlers::folder_handler::list_folder_contents_paginated,
|
2026-05-31 00:26:21 +02:00
|
|
|
handlers::folder_handler::list_folder_resources,
|
2026-04-27 22:59:18 +02:00
|
|
|
handlers::folder_handler::list_folder_listing,
|
|
|
|
|
handlers::folder_handler::rename_folder,
|
|
|
|
|
handlers::folder_handler::move_folder,
|
|
|
|
|
handlers::folder_handler::delete_folder_with_trash,
|
|
|
|
|
handlers::folder_handler::download_folder_zip,
|
|
|
|
|
// Search handlers (free functions — see search_handler.rs for why)
|
|
|
|
|
handlers::search_handler::search_files_get,
|
|
|
|
|
handlers::search_handler::search_files_post,
|
|
|
|
|
handlers::search_handler::suggest_files,
|
|
|
|
|
handlers::search_handler::clear_search_cache,
|
|
|
|
|
// i18n handlers (free functions — see i18n_handler.rs for why)
|
|
|
|
|
handlers::i18n_handler::get_locales,
|
|
|
|
|
handlers::i18n_handler::translate,
|
|
|
|
|
handlers::i18n_handler::get_translations_by_locale,
|
|
|
|
|
// Chunked upload handlers — all five are free functions (not impl methods) because
|
|
|
|
|
// utoipa 5.4.0 cannot annotate methods on ChunkedUploadHandler; see handler file.
|
|
|
|
|
handlers::chunked_upload_handler::create_upload,
|
|
|
|
|
handlers::chunked_upload_handler::upload_chunk,
|
|
|
|
|
handlers::chunked_upload_handler::get_upload_status,
|
|
|
|
|
handlers::chunked_upload_handler::complete_upload,
|
|
|
|
|
handlers::chunked_upload_handler::cancel_upload,
|
|
|
|
|
// Dedup handlers — all free functions for the same utoipa reason as chunked uploads.
|
|
|
|
|
handlers::dedup_handler::check_hash,
|
|
|
|
|
handlers::dedup_handler::upload_with_dedup,
|
|
|
|
|
handlers::dedup_handler::get_stats,
|
|
|
|
|
handlers::dedup_handler::get_blob,
|
|
|
|
|
handlers::dedup_handler::recalculate_stats,
|
|
|
|
|
// Trash handlers (free functions)
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::trash_handler::get_trash_items,
|
2026-05-30 00:15:07 +02:00
|
|
|
handlers::trash_handler::get_trash_resources,
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::trash_handler::move_file_to_trash,
|
|
|
|
|
handlers::trash_handler::move_folder_to_trash,
|
|
|
|
|
handlers::trash_handler::restore_from_trash,
|
|
|
|
|
handlers::trash_handler::delete_permanently,
|
|
|
|
|
handlers::trash_handler::empty_trash,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Share handlers (free functions)
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::share_handler::create_shared_link,
|
|
|
|
|
handlers::share_handler::get_shared_link,
|
|
|
|
|
handlers::share_handler::get_user_shares,
|
|
|
|
|
handlers::share_handler::update_shared_link,
|
|
|
|
|
handlers::share_handler::delete_shared_link,
|
|
|
|
|
handlers::share_handler::access_shared_item,
|
|
|
|
|
handlers::share_handler::verify_shared_item_password,
|
2026-04-27 22:59:18 +02:00
|
|
|
handlers::share_handler::download_shared_file,
|
2026-05-14 00:50:10 +02:00
|
|
|
handlers::share_handler::list_share_contents_root,
|
|
|
|
|
handlers::share_handler::list_share_contents_subfolder,
|
|
|
|
|
handlers::share_handler::download_share_file_in_folder,
|
|
|
|
|
handlers::share_handler::download_share_zip_root,
|
|
|
|
|
handlers::share_handler::download_share_zip_subfolder,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Favorites handlers (free functions)
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::favorites_handler::get_favorites,
|
2026-05-31 00:26:21 +02:00
|
|
|
handlers::favorites_handler::list_favorites_resources,
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::favorites_handler::add_favorite,
|
|
|
|
|
handlers::favorites_handler::remove_favorite,
|
|
|
|
|
handlers::favorites_handler::batch_add_favorites,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Recent handlers (free functions)
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::recent_handler::get_recent_items,
|
2026-05-31 00:26:21 +02:00
|
|
|
handlers::recent_handler::list_recent_resources,
|
2026-03-29 18:49:10 +02:00
|
|
|
handlers::recent_handler::record_item_access,
|
|
|
|
|
handlers::recent_handler::remove_from_recent,
|
|
|
|
|
handlers::recent_handler::clear_recent_items,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Photos handler (free function)
|
|
|
|
|
handlers::photos_handler::list_photos,
|
|
|
|
|
// Batch handlers (free functions)
|
|
|
|
|
handlers::batch_handler::move_files_batch,
|
|
|
|
|
handlers::batch_handler::copy_files_batch,
|
2026-05-31 00:26:21 +02:00
|
|
|
handlers::batch_handler::copy_folders_batch,
|
2026-04-27 22:59:18 +02:00
|
|
|
handlers::batch_handler::delete_files_batch,
|
|
|
|
|
handlers::batch_handler::get_files_batch,
|
|
|
|
|
handlers::batch_handler::delete_folders_batch,
|
|
|
|
|
handlers::batch_handler::create_folders_batch,
|
|
|
|
|
handlers::batch_handler::get_folders_batch,
|
|
|
|
|
handlers::batch_handler::move_folders_batch,
|
|
|
|
|
handlers::batch_handler::trash_batch,
|
2026-05-04 22:41:29 +02:00
|
|
|
handlers::batch_handler::download_batch_post,
|
|
|
|
|
handlers::batch_handler::download_batch_querystring,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Music/playlist handlers (free functions)
|
|
|
|
|
handlers::music_handler::create_playlist,
|
|
|
|
|
handlers::music_handler::list_playlists,
|
|
|
|
|
handlers::music_handler::get_playlist,
|
|
|
|
|
handlers::music_handler::update_playlist,
|
|
|
|
|
handlers::music_handler::delete_playlist,
|
|
|
|
|
handlers::music_handler::list_playlist_tracks,
|
|
|
|
|
handlers::music_handler::add_tracks,
|
|
|
|
|
handlers::music_handler::remove_track,
|
|
|
|
|
handlers::music_handler::reorder_tracks,
|
|
|
|
|
handlers::music_handler::share_playlist,
|
|
|
|
|
handlers::music_handler::remove_share,
|
|
|
|
|
handlers::music_handler::get_playlist_shares,
|
|
|
|
|
handlers::music_handler::get_audio_metadata,
|
2026-05-09 19:18:33 +02:00
|
|
|
// Contacts / address-book handlers (free functions)
|
|
|
|
|
handlers::contacts_handler::list_address_books,
|
|
|
|
|
handlers::contacts_handler::create_address_book,
|
|
|
|
|
handlers::contacts_handler::update_address_book,
|
|
|
|
|
handlers::contacts_handler::delete_address_book,
|
|
|
|
|
handlers::contacts_handler::list_contacts,
|
|
|
|
|
handlers::contacts_handler::create_contact,
|
|
|
|
|
handlers::contacts_handler::get_contact,
|
|
|
|
|
handlers::contacts_handler::update_contact,
|
|
|
|
|
handlers::contacts_handler::delete_contact,
|
|
|
|
|
handlers::contacts_handler::list_groups,
|
|
|
|
|
handlers::contacts_handler::create_group,
|
|
|
|
|
handlers::contacts_handler::get_group,
|
|
|
|
|
handlers::contacts_handler::update_group,
|
|
|
|
|
handlers::contacts_handler::delete_group,
|
|
|
|
|
handlers::contacts_handler::list_contacts_in_group,
|
|
|
|
|
handlers::contacts_handler::add_contact_to_group,
|
|
|
|
|
handlers::contacts_handler::remove_contact_from_group,
|
2026-04-27 22:59:18 +02:00
|
|
|
// Admin handlers (pub free functions)
|
|
|
|
|
handlers::admin_handler::get_dashboard_stats,
|
|
|
|
|
handlers::admin_handler::list_users,
|
|
|
|
|
handlers::admin_handler::get_user,
|
|
|
|
|
handlers::admin_handler::create_user,
|
|
|
|
|
handlers::admin_handler::delete_user,
|
|
|
|
|
handlers::admin_handler::update_user_role,
|
|
|
|
|
handlers::admin_handler::update_user_active,
|
|
|
|
|
handlers::admin_handler::update_user_quota,
|
|
|
|
|
handlers::admin_handler::reset_user_password,
|
|
|
|
|
handlers::admin_handler::get_registration_setting,
|
|
|
|
|
handlers::admin_handler::set_registration_setting,
|
|
|
|
|
handlers::admin_handler::get_general_settings,
|
|
|
|
|
handlers::admin_handler::get_oidc_settings,
|
|
|
|
|
handlers::admin_handler::save_oidc_settings,
|
|
|
|
|
handlers::admin_handler::get_storage_settings,
|
|
|
|
|
handlers::admin_handler::save_storage_settings,
|
|
|
|
|
handlers::admin_handler::get_migration_status,
|
|
|
|
|
handlers::admin_handler::start_migration,
|
|
|
|
|
handlers::admin_handler::pause_migration,
|
|
|
|
|
handlers::admin_handler::resume_migration,
|
|
|
|
|
handlers::admin_handler::complete_migration,
|
|
|
|
|
handlers::admin_handler::verify_migration,
|
|
|
|
|
handlers::admin_handler::generate_encryption_key,
|
2026-05-23 23:51:32 +02:00
|
|
|
// Grant / ReBAC handlers (free functions)
|
|
|
|
|
handlers::grant_handler::create_grant,
|
|
|
|
|
handlers::grant_handler::revoke_grant,
|
|
|
|
|
handlers::grant_handler::set_role,
|
|
|
|
|
handlers::grant_handler::list_incoming,
|
2026-05-24 01:05:13 +02:00
|
|
|
handlers::grant_handler::list_shared_with_me,
|
2026-05-23 23:51:32 +02:00
|
|
|
handlers::grant_handler::list_outgoing,
|
2026-05-31 00:26:21 +02:00
|
|
|
handlers::grant_handler::list_my_shares,
|
2026-05-23 23:51:32 +02:00
|
|
|
handlers::grant_handler::list_on_resource,
|
2026-05-30 23:35:47 +02:00
|
|
|
// Subject-group handlers (ReBAC named groups) — free functions
|
|
|
|
|
handlers::subject_group_handler::create_group,
|
|
|
|
|
handlers::subject_group_handler::list_groups,
|
|
|
|
|
handlers::subject_group_handler::search_groups,
|
|
|
|
|
handlers::subject_group_handler::get_group,
|
|
|
|
|
handlers::subject_group_handler::update_group,
|
|
|
|
|
handlers::subject_group_handler::delete_group,
|
|
|
|
|
handlers::subject_group_handler::list_members,
|
|
|
|
|
handlers::subject_group_handler::add_member,
|
|
|
|
|
handlers::subject_group_handler::remove_user_member,
|
|
|
|
|
handlers::subject_group_handler::remove_group_member,
|
|
|
|
|
handlers::subject_group_handler::list_effective_members,
|
2026-03-29 18:49:10 +02:00
|
|
|
),
|
|
|
|
|
components(
|
|
|
|
|
schemas(
|
|
|
|
|
// Folder schemas
|
|
|
|
|
FolderDto,
|
|
|
|
|
CreateFolderDto,
|
|
|
|
|
RenameFolderDto,
|
|
|
|
|
MoveFolderDto,
|
|
|
|
|
FolderListingDto,
|
2026-05-31 00:26:21 +02:00
|
|
|
FolderResourceItemDto,
|
|
|
|
|
ResourceContentDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
// File schemas
|
|
|
|
|
FileDto,
|
2026-06-11 14:34:02 +00:00
|
|
|
// Delta-upload schemas
|
|
|
|
|
crate::application::services::delta_upload_service::ChunkRef,
|
|
|
|
|
crate::application::services::delta_upload_service::DeltaNegotiateRequest,
|
|
|
|
|
crate::application::services::delta_upload_service::DeltaNegotiateResponse,
|
|
|
|
|
crate::application::services::delta_upload_service::DeltaChunksResponse,
|
|
|
|
|
crate::application::services::delta_upload_service::DeltaCommitRequest,
|
|
|
|
|
handlers::delta_upload_handler::DeltaStillMissingResponse,
|
2026-03-29 18:49:10 +02:00
|
|
|
MoveFilePayload,
|
|
|
|
|
PaginationDto,
|
|
|
|
|
PaginationRequestDto,
|
|
|
|
|
// User / Auth schemas
|
|
|
|
|
UserDto,
|
|
|
|
|
LoginDto,
|
|
|
|
|
RegisterDto,
|
|
|
|
|
SetupAdminDto,
|
|
|
|
|
AuthResponseDto,
|
|
|
|
|
ChangePasswordDto,
|
|
|
|
|
RefreshTokenDto,
|
2026-05-28 00:20:21 +02:00
|
|
|
SystemStatus,
|
|
|
|
|
OidcProviderInfoDto,
|
|
|
|
|
OidcExchangeDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
// Share schemas
|
|
|
|
|
ShareDto,
|
|
|
|
|
CreateShareDto,
|
|
|
|
|
UpdateShareDto,
|
|
|
|
|
// Trash schemas
|
|
|
|
|
TrashedItemDto,
|
2026-05-30 00:15:07 +02:00
|
|
|
TrashResourceItemDto,
|
|
|
|
|
TrashResourcesDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
MoveToTrashRequest,
|
|
|
|
|
RestoreFromTrashRequest,
|
|
|
|
|
DeletePermanentlyRequest,
|
|
|
|
|
// Search schemas
|
|
|
|
|
SearchCriteriaDto,
|
|
|
|
|
SearchResultsDto,
|
|
|
|
|
SearchFileResultDto,
|
|
|
|
|
SearchFolderResultDto,
|
|
|
|
|
SearchSuggestionsDto,
|
|
|
|
|
SearchSuggestionItem,
|
|
|
|
|
// Favorites schemas
|
|
|
|
|
FavoriteItemDto,
|
2026-05-31 00:26:21 +02:00
|
|
|
FavoritesResourceItemDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
BatchFavoritesResult,
|
|
|
|
|
BatchFavoritesStats,
|
|
|
|
|
// Recent schemas
|
|
|
|
|
RecentItemDto,
|
2026-05-31 00:26:21 +02:00
|
|
|
RecentResourceItemDto,
|
2026-04-27 22:59:18 +02:00
|
|
|
// i18n schemas
|
|
|
|
|
LocaleDto,
|
|
|
|
|
TranslationRequestDto,
|
|
|
|
|
TranslationResponseDto,
|
|
|
|
|
TranslationErrorDto,
|
|
|
|
|
// Chunked upload schemas
|
|
|
|
|
CreateUploadRequest,
|
|
|
|
|
CompleteUploadResponse,
|
|
|
|
|
CreateUploadResponseDto,
|
|
|
|
|
ChunkUploadResponseDto,
|
|
|
|
|
UploadStatusResponseDto,
|
|
|
|
|
// Dedup schemas
|
|
|
|
|
HashCheckResponse,
|
|
|
|
|
DedupUploadResponse,
|
|
|
|
|
StatsResponse,
|
2026-05-09 19:18:33 +02:00
|
|
|
// Contacts / address-book schemas
|
|
|
|
|
AddressBookResponse,
|
|
|
|
|
CreateAddressBookRequest,
|
|
|
|
|
UpdateAddressBookRequest,
|
|
|
|
|
ContactDto,
|
|
|
|
|
ContactGroupDto,
|
|
|
|
|
EmailDto,
|
|
|
|
|
PhoneDto,
|
|
|
|
|
AddressDto,
|
|
|
|
|
CreateContactRequest,
|
|
|
|
|
UpdateContactRequest,
|
|
|
|
|
GroupNameRequest,
|
|
|
|
|
AddMemberRequest,
|
2026-05-23 23:51:32 +02:00
|
|
|
// Grant / ReBAC schemas
|
|
|
|
|
SubjectTypeDto,
|
|
|
|
|
SubjectDto,
|
|
|
|
|
ResourceTypeDto,
|
|
|
|
|
ResourceDto,
|
|
|
|
|
PermissionDto,
|
|
|
|
|
Role,
|
|
|
|
|
CreateGrantDto,
|
|
|
|
|
UpdateRoleDto,
|
|
|
|
|
GrantDto,
|
2026-05-24 01:05:13 +02:00
|
|
|
SharedWithMeDto,
|
|
|
|
|
SharedWithMeItemDto,
|
2026-05-31 00:26:21 +02:00
|
|
|
OutgoingResourceItemDto,
|
2026-05-30 23:35:47 +02:00
|
|
|
// Subject-group (ReBAC named groups) schemas
|
|
|
|
|
handlers::subject_group_handler::CreateGroupRequest,
|
|
|
|
|
handlers::subject_group_handler::UpdateGroupRequest,
|
|
|
|
|
handlers::subject_group_handler::AddSubjectGroupMemberRequest,
|
|
|
|
|
handlers::subject_group_handler::GroupDto,
|
|
|
|
|
handlers::subject_group_handler::GroupListDto,
|
|
|
|
|
handlers::subject_group_handler::GroupMemberDto,
|
2026-03-29 18:49:10 +02:00
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
tags(
|
2026-05-28 00:20:21 +02:00
|
|
|
(name = "auth", description = "Authentication and session management endpoints"),
|
2026-03-29 18:49:10 +02:00
|
|
|
(name = "files", description = "File management endpoints"),
|
2026-04-27 22:59:18 +02:00
|
|
|
(name = "folders", description = "Folder management endpoints"),
|
2026-03-29 18:49:10 +02:00
|
|
|
(name = "trash", description = "Trash / recycle bin endpoints"),
|
|
|
|
|
(name = "search", description = "Search endpoints"),
|
|
|
|
|
(name = "shares", description = "Shared links endpoints"),
|
|
|
|
|
(name = "favorites", description = "Favorites management endpoints"),
|
|
|
|
|
(name = "recent", description = "Recent items endpoints"),
|
2026-04-27 22:59:18 +02:00
|
|
|
(name = "photos", description = "Photos timeline endpoints"),
|
|
|
|
|
(name = "i18n", description = "Internationalisation endpoints"),
|
|
|
|
|
(name = "uploads", description = "Chunked / resumable upload endpoints"),
|
|
|
|
|
(name = "dedup", description = "Content deduplication endpoints"),
|
|
|
|
|
(name = "batch", description = "Batch operation endpoints"),
|
|
|
|
|
(name = "playlists", description = "Music playlist endpoints"),
|
2026-05-09 19:18:33 +02:00
|
|
|
(name = "contacts", description = "Address books, contacts, and groups endpoints"),
|
2026-04-27 22:59:18 +02:00
|
|
|
(name = "admin", description = "Admin management endpoints"),
|
2026-05-23 23:51:32 +02:00
|
|
|
(name = "grants", description = "ReBAC grant management endpoints"),
|
2026-05-30 23:35:47 +02:00
|
|
|
(name = "groups", description = "ReBAC subject-group management endpoints (named, nestable, root-owned)"),
|
2026-03-29 18:49:10 +02:00
|
|
|
),
|
|
|
|
|
info(
|
|
|
|
|
title = "OxiCloud API",
|
|
|
|
|
version = env!("CARGO_PKG_VERSION"),
|
|
|
|
|
description = "REST API for OxiCloud — self-hosted cloud storage, calendar & contacts",
|
|
|
|
|
license(name = "MIT")
|
|
|
|
|
)
|
|
|
|
|
)]
|
|
|
|
|
pub struct ApiDoc;
|
2026-04-01 12:25:10 +02:00
|
|
|
|
2026-05-28 00:20:21 +02:00
|
|
|
/// Injects the `bearerAuth` HTTP Bearer security scheme into the generated spec.
|
|
|
|
|
struct SecurityAddon;
|
|
|
|
|
|
|
|
|
|
impl Modify for SecurityAddon {
|
|
|
|
|
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
|
|
|
|
|
let components = openapi.components.get_or_insert_with(Default::default);
|
|
|
|
|
components.add_security_scheme(
|
|
|
|
|
"bearerAuth",
|
|
|
|
|
SecurityScheme::Http(Http::new(HttpAuthScheme::Bearer)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-01 12:25:10 +02:00
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn openapi_spec_is_valid_and_has_expected_structure() {
|
|
|
|
|
let spec = ApiDoc::openapi();
|
|
|
|
|
|
|
|
|
|
assert_eq!(spec.info.title, "OxiCloud API");
|
|
|
|
|
assert!(!spec.info.version.is_empty());
|
|
|
|
|
|
|
|
|
|
let paths = &spec.paths;
|
|
|
|
|
assert!(
|
|
|
|
|
paths.paths.len() >= 10,
|
|
|
|
|
"expected at least 10 paths, got {}",
|
|
|
|
|
paths.paths.len()
|
|
|
|
|
);
|
|
|
|
|
assert!(paths.paths.contains_key("/api/trash"), "missing /api/trash");
|
|
|
|
|
assert!(
|
|
|
|
|
paths.paths.contains_key("/api/shares"),
|
|
|
|
|
"missing /api/shares"
|
|
|
|
|
);
|
|
|
|
|
assert!(
|
|
|
|
|
paths.paths.contains_key("/api/favorites"),
|
|
|
|
|
"missing /api/favorites"
|
|
|
|
|
);
|
|
|
|
|
assert!(
|
|
|
|
|
paths.paths.contains_key("/api/recent"),
|
|
|
|
|
"missing /api/recent"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let schemas = &spec
|
|
|
|
|
.components
|
|
|
|
|
.as_ref()
|
|
|
|
|
.expect("components missing")
|
|
|
|
|
.schemas;
|
|
|
|
|
assert!(
|
|
|
|
|
schemas.len() >= 25,
|
|
|
|
|
"expected at least 25 schemas, got {}",
|
|
|
|
|
schemas.len()
|
|
|
|
|
);
|
|
|
|
|
for name in [
|
|
|
|
|
"FileDto",
|
|
|
|
|
"FolderDto",
|
|
|
|
|
"ShareDto",
|
|
|
|
|
"TrashedItemDto",
|
|
|
|
|
"UserDto",
|
|
|
|
|
] {
|
|
|
|
|
assert!(schemas.contains_key(name), "missing schema: {name}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let json = serde_json::to_string(&spec).expect("spec should serialise to JSON");
|
|
|
|
|
assert!(json.len() > 1000, "spec JSON suspiciously small");
|
|
|
|
|
}
|
|
|
|
|
}
|