docs: add utoipa OpenAPI annotations to all scraper endpoints
Deploy Scraper / build-and-deploy (push) Canceled after 0s
Deploy Scraper / build-and-deploy (push) Canceled after 0s
Add #[utoipa::path] + IntoParams to all new category handlers: - downloader (25 routes): /download, /detect-platform, 23 platform handlers - misc (4): currency-converter, harga-emas, kurs-bca, server-info - stalk (8): github, youtube, ml, free-fire, genshin, twitter, tiktok, instagram - weebs (5): anime-info, manga-info, whatanime, waifu (sfw/nsfw) - search (5): bmkg, jadwal-sholat, weather, google, yt - tool (6): whois, ip-location, tinyurl, check-hosting, hargapangan, cek-resi - image (2): brat, brat-animated - uploader (2): ryzencdn, serve-file - ai (3): chat, gemini, image Register all in ModuleApiDoc paths() with per-category tags. Fix clippy warnings in touched handlers (expect/unwrap -> map_err, needless lifetimes). /docs now documents the full scraper API surface (was only anime/komik).
This commit is contained in:
1 parent
e6f543078b
commit
bbb8bed389
10 files changed
+879
-58
No files matched your search
@@ -7,12 +7,13 @@ use axum::http::StatusCode;
|
||||
use axum::Json;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
use utoipa::IntoParams;
|
||||
|
||||
use crate::application::misc as use_cases;
|
||||
use crate::presentation::error::AppError;
|
||||
|
||||
/// Query params for currency converter.
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, IntoParams)]
|
||||
pub struct CurrencyParams {
|
||||
pub amount: Option<f64>,
|
||||
pub from: Option<String>,
|
||||
@@ -20,6 +21,17 @@ pub struct CurrencyParams {
|
||||
}
|
||||
|
||||
/// GET /misc/currency-converter?amount=100&from=USD&to=IDR
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/misc/currency-converter",
|
||||
tag = "misc",
|
||||
operation_id = "currency_converter",
|
||||
params(CurrencyParams),
|
||||
responses(
|
||||
(status = 200, description = "Currency conversion result", body = Value),
|
||||
(status = 502, description = "Upstream error"),
|
||||
)
|
||||
)]
|
||||
pub async fn currency_converter_handler(
|
||||
Query(params): Query<CurrencyParams>,
|
||||
) -> Result<(StatusCode, Json<Value>), AppError> {
|
||||
@@ -32,18 +44,48 @@ pub async fn currency_converter_handler(
|
||||
}
|
||||
|
||||
/// GET /misc/harga-emas
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/misc/harga-emas",
|
||||
tag = "misc",
|
||||
operation_id = "harga_emas",
|
||||
responses(
|
||||
(status = 200, description = "Gold prices (Antam)", body = Value),
|
||||
(status = 502, description = "Upstream error"),
|
||||
)
|
||||
)]
|
||||
pub async fn harga_emas_handler() -> Result<(StatusCode, Json<Value>), AppError> {
|
||||
let result = use_cases::harga_emas().await?;
|
||||
Ok((StatusCode::OK, Json(result)))
|
||||
}
|
||||
|
||||
/// GET /misc/kurs-bca
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/misc/kurs-bca",
|
||||
tag = "misc",
|
||||
operation_id = "kurs_bca",
|
||||
responses(
|
||||
(status = 200, description = "BCA exchange rates", body = Value),
|
||||
(status = 502, description = "Upstream error"),
|
||||
)
|
||||
)]
|
||||
pub async fn kurs_bca_handler() -> Result<(StatusCode, Json<Value>), AppError> {
|
||||
let result = use_cases::kurs_bca().await?;
|
||||
Ok((StatusCode::OK, Json(result)))
|
||||
}
|
||||
|
||||
/// GET /misc/server-info
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/misc/server-info",
|
||||
tag = "misc",
|
||||
operation_id = "server_info",
|
||||
responses(
|
||||
(status = 200, description = "Server info", body = Value),
|
||||
(status = 502, description = "Upstream error"),
|
||||
)
|
||||
)]
|
||||
pub async fn server_info_handler() -> Result<(StatusCode, Json<Value>), AppError> {
|
||||
let result = use_cases::server_info().await?;
|
||||
Ok((StatusCode::OK, Json(result)))
|
||||
|
||||
Reference in new issue
Block a user