pinakes-server: add utoipa annotations to all routes; fix tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
This commit is contained in:
parent
67b8322705
commit
9d58927cb4
60 changed files with 3493 additions and 242 deletions
|
|
@ -36,7 +36,7 @@ const fn default_timeline_limit() -> u64 {
|
|||
}
|
||||
|
||||
/// Timeline group response
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct TimelineGroup {
|
||||
pub date: String,
|
||||
pub count: usize,
|
||||
|
|
@ -54,7 +54,7 @@ pub struct MapQuery {
|
|||
}
|
||||
|
||||
/// Map marker response
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct MapMarker {
|
||||
pub id: String,
|
||||
pub latitude: f64,
|
||||
|
|
@ -63,6 +63,23 @@ pub struct MapMarker {
|
|||
pub date_taken: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/photos/timeline",
|
||||
tag = "photos",
|
||||
params(
|
||||
("group_by" = Option<String>, Query, description = "Grouping: day, month, year"),
|
||||
("year" = Option<i32>, Query, description = "Filter by year"),
|
||||
("month" = Option<u32>, Query, description = "Filter by month"),
|
||||
("limit" = Option<u64>, Query, description = "Max items (default 10000)"),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Photo timeline groups", body = Vec<TimelineGroup>),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
/// Get timeline of photos grouped by date
|
||||
pub async fn get_timeline(
|
||||
State(state): State<AppState>,
|
||||
|
|
@ -147,6 +164,24 @@ pub async fn get_timeline(
|
|||
Ok(Json(timeline))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/photos/map",
|
||||
tag = "photos",
|
||||
params(
|
||||
("lat1" = f64, Query, description = "Bounding box latitude 1"),
|
||||
("lon1" = f64, Query, description = "Bounding box longitude 1"),
|
||||
("lat2" = f64, Query, description = "Bounding box latitude 2"),
|
||||
("lon2" = f64, Query, description = "Bounding box longitude 2"),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Map markers", body = Vec<MapMarker>),
|
||||
(status = 400, description = "Bad request"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
/// Get photos in a bounding box for map view
|
||||
pub async fn get_map_photos(
|
||||
State(state): State<AppState>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue