web search done right
webgraph api endpoints in docs
Mikkel Denker00eda369845a
diff --git a/core/src/api/docs.rs b/core/src/api/docs.rsindex 0c2d73fa..0f890964 100644--- a/core/src/api/docs.rs+++ b/core/src/api/docs.rs@@ -14,7 +14,7 @@// You should have received a copy of the GNU Affero General Public License// along with this program. If not, see <https://www.gnu.org/licenses/>.-use super::search;+use super::{search, webgraph};use axum::Router;use utoipa::{Modify, OpenApi};use utoipa_swagger_ui::SwaggerUi;@@ -23,6 +23,8 @@ use utoipa_swagger_ui::SwaggerUi;#[openapi(paths(search::api,+ webgraph::similar_sites,+ webgraph::knows_site),components(schemas(@@ -49,6 +51,10 @@ use utoipa_swagger_ui::SwaggerUi;crate::ranking::signal::SignalScore,crate::bangs::BangHit,crate::bangs::Bang,++ webgraph::SimilarSitesParams,+ webgraph::KnowsSite,+ crate::entrypoint::webgraph_server::ScoredSite,),),modifiers(&ApiModifier),diff --git a/core/src/api/webgraph.rs b/core/src/api/webgraph.rsindex 4d785d3e..02e006bb 100644--- a/core/src/api/webgraph.rs+++ b/core/src/api/webgraph.rs@@ -18,6 +18,7 @@ use std::{net::SocketAddr, sync::Arc, time::Duration};use axum::{extract, response::IntoResponse, Json};use http::StatusCode;+use utoipa::{IntoParams, ToSchema};use crate::distributed::{cluster::Cluster, member::Service, retry_strategy::ExponentialBackoff, sonic,@@ -47,13 +48,20 @@ impl RemoteWebgraph {}}-#[derive(serde::Deserialize)]+#[derive(serde::Deserialize, ToSchema)]pub struct SimilarSitesParams {pub sites: Vec<String>,pub top_n: usize,}#[allow(clippy::unused_async)]+#[utoipa::path(post,+ path = "/beta/api/webgraph/similar_sites",+ request_body(content = SimilarSitesParams),+ responses(+ (status = 200, description = "List of similar sites", body = Vec<ScoredSite>),+ )+)]pub async fn similar_sites(extract::State(state): extract::State<Arc<State>>,extract::Json(params): extract::Json<SimilarSitesParams>,@@ -91,12 +99,12 @@ pub async fn similar_sites(}}-#[derive(serde::Deserialize)]+#[derive(serde::Deserialize, IntoParams)]pub struct KnowsSiteParams {pub site: String,}-#[derive(serde::Serialize, serde::Deserialize)]+#[derive(serde::Serialize, serde::Deserialize, ToSchema)]#[serde(tag = "@type", rename_all = "camelCase")]pub enum KnowsSite {Known { site: String },@@ -104,6 +112,13 @@ pub enum KnowsSite {}#[allow(clippy::unused_async)]+#[utoipa::path(post,+ path = "/beta/api/webgraph/knows_site",+ params(KnowsSiteParams),+ responses(+ (status = 200, description = "Whether the site is known", body = KnowsSite),+ )+)]pub async fn knows_site(extract::State(state): extract::State<Arc<State>>,extract::Query(params): extract::Query<KnowsSiteParams>,diff --git a/core/src/entrypoint/webgraph_server.rs b/core/src/entrypoint/webgraph_server.rsindex aebb18fb..7979c40b 100644--- a/core/src/entrypoint/webgraph_server.rs+++ b/core/src/entrypoint/webgraph_server.rs@@ -22,6 +22,7 @@ use serde::Deserialize;use serde::Serialize;use tracing::info;use url::Url;+use utoipa::ToSchema;use crate::config;use crate::distributed::cluster::Cluster;@@ -37,7 +38,7 @@ use crate::webgraph::Node;use crate::webgraph::WebgraphBuilder;use crate::Result;-#[derive(serde::Serialize, serde::Deserialize)]+#[derive(serde::Serialize, serde::Deserialize, ToSchema)]pub struct ScoredSite {pub site: String,pub score: f64,