From 0a058ba2064d323451462a79c71580dea7d8ec8c Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 4 Mar 2024 21:37:55 +0100 Subject: Closes #19. Added OpenApi through `utoipa` --- src/routes/start.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/routes/start.rs') diff --git a/src/routes/start.rs b/src/routes/start.rs index d4c0802..ef6e8f2 100644 --- a/src/routes/start.rs +++ b/src/routes/start.rs @@ -6,10 +6,20 @@ use axum::extract::State; use axum::Json; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; +use utoipa::ToSchema; use std::sync::Arc; use tracing::{debug, info}; use uuid::Uuid; +#[utoipa::path( + post, + path = "/start", + request_body = Payload, + responses( + (status = 200, description = "List matching todos by query", body = [Response]) + ), + security(("api_key" = [])) +)] pub async fn start( State(state): State>, Json(payload): Json, @@ -88,14 +98,14 @@ fn setup_ping(state: Arc, device: Device) -> String { uuid_ret } -#[derive(Deserialize)] +#[derive(Deserialize, ToSchema)] pub struct Payload { id: String, ping: Option, } -#[derive(Serialize)] -struct Response { +#[derive(Serialize, ToSchema)] +pub struct Response { id: String, boot: bool, uuid: Option, -- cgit v1.2.3