open api finish
parent
766cf9ea0c
commit
4514ecdfce
|
|
@ -17,3 +17,4 @@ tracing = "0.1.41"
|
|||
tracing-subscriber = "0.3.19"
|
||||
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||
utoipa-axum = "0.2.0"
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,25 @@
|
|||
use crate::schemas::InputMetric;
|
||||
use crate::endpoints::rest::__path_model_rest_handler;
|
||||
use utoipa::OpenApi;
|
||||
|
||||
#[derive(utoipa::OpenApi)]
|
||||
#[openapi(paths(model_rest_handler))]
|
||||
struct ApiDoc;
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
info(
|
||||
title = "ML-API",
|
||||
version = "0.1.0",
|
||||
description = "API for communication with the Model",
|
||||
contact(
|
||||
name = "Vladislav Drozdov",
|
||||
email = "_@_",
|
||||
url = "https://___"
|
||||
)
|
||||
),
|
||||
paths(model_rest_handler),
|
||||
components(
|
||||
schemas(InputMetric)
|
||||
),
|
||||
tags(
|
||||
(name = "models", description = "API for communication with the Model")
|
||||
)
|
||||
)]
|
||||
pub struct ApiDoc;
|
||||
|
|
@ -21,14 +21,14 @@ pub mod rest {
|
|||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
summary = "An endpoint using to REST communication with the Model",
|
||||
path = "/api/metrics/rest",
|
||||
request_body = Vec<InputMetric>,
|
||||
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"),
|
||||
)
|
||||
(status = 200, description = "Model successfully processed all given data and"),
|
||||
(status = 500, description = "Some errors with model"),
|
||||
),
|
||||
tag = "query"
|
||||
)]
|
||||
pub async fn model_rest_handler(
|
||||
State(config) : State<Config>,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use std::sync::Arc;
|
|||
use tracing::{debug, info, trace};
|
||||
use dotenv::dotenv;
|
||||
use endpoints::{
|
||||
openapi::swagger,
|
||||
rest::model_rest_handler,
|
||||
ws::model_ws_handler,
|
||||
};
|
||||
|
|
@ -18,6 +17,9 @@ use axum::{
|
|||
routing::get,
|
||||
Router};
|
||||
use lazy_static::lazy_static;
|
||||
use utoipa_swagger_ui::SwaggerUi;
|
||||
use api_docs::ApiDoc;
|
||||
use utoipa::OpenApi;
|
||||
|
||||
lazy_static! {
|
||||
static ref PROMPT: String = String::from("\n проанализируй ВЕСЬ этот список метрик системы, обращая внимание на статусы КАЖДОЙ МЕТРИКИ:\n 0 - не определен \n 1 - норма \n 2 - предупреждение \n 3 - критично \n 4 - авария \n напиши общую подробную оценку системы с указанием вообще всех слабых мест и рекомендаций по устранению проблем (ВАЖНО!!! : только на русском языке без форматирования и лишнего текста, без комментариев, только оценка и рекомендации) \n ВАЖНО! НЕ ИСПОЛЬЗУЙ MD-форматирование выходного текста, анализируй метрики выше и по ним делай выводы и рекомендации");
|
||||
|
|
@ -39,7 +41,8 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
let router = Router::new()
|
||||
.nest("/api/metrics", api)
|
||||
.route("/swagger", get(swagger));
|
||||
.merge(SwaggerUi::new("/swagger").url("/api-docs/openapi.json", ApiDoc::openapi()));
|
||||
// .route("/swagger", get(swagger));
|
||||
|
||||
debug!("router for app : {:?}", router);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue