api start

master
prplV 2025-06-25 03:23:50 -04:00
parent ddea3b51bb
commit 766cf9ea0c
5 changed files with 19 additions and 1 deletions

View File

@ -15,4 +15,5 @@ serde_json = "1.0.140"
tokio = { version = "1.45.1", features = ["full"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
utoipa = { version = "5.4.0", features = ["axum_extras"] }
utoipa-axum = "0.2.0"

5
src/api_docs.rs Normal file
View File

@ -0,0 +1,5 @@
use crate::endpoints::rest::__path_model_rest_handler;
#[derive(utoipa::OpenApi)]
#[openapi(paths(model_rest_handler))]
struct ApiDoc;

View File

@ -19,6 +19,17 @@ pub mod rest {
use tracing::trace;
use super::{IntoResponse, StatusCode, InputMetric, Json, Config, State};
#[utoipa::path(
get,
path = "/api/metrics/rest",
responses(
(status = 200, description = "Model successfully processed all given data and"),
(status = 500, description = "Some errors with model")
),
params(
("metrics" = Vec<InputMetric>, Path, description = "Metrics list to work with"),
)
)]
pub async fn model_rest_handler(
State(config) : State<Config>,
Json(req) : Json<Vec<InputMetric>>,

View File

@ -2,6 +2,7 @@ mod endpoints;
mod schemas;
mod models;
mod setup;
mod api_docs;
use std::sync::Arc;
use tracing::{debug, info, trace};

View File

@ -1,6 +1,6 @@
use serde::{Serialize, Deserialize};
#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, utoipa::ToSchema)]
pub struct InputMetric {
id : String,
name : String,