From 87a165308a97ba9c5c89e0695914fc8c591bc1bf Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Fri, 1 Mar 2024 12:50:53 +0000 Subject: [PATCH] Added network openapi documentation --- rust/agama-server/src/network/model.rs | 6 +++--- rust/agama-server/src/web/docs.rs | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/rust/agama-server/src/network/model.rs b/rust/agama-server/src/network/model.rs index 1bad95d5e1..4ff3d7392e 100644 --- a/rust/agama-server/src/network/model.rs +++ b/rust/agama-server/src/network/model.rs @@ -18,7 +18,7 @@ use thiserror::Error; use uuid::Uuid; use zbus::zvariant::Value; -#[derive(Default, Clone, Debug)] +#[derive(Default, Clone, Debug, utoipa::ToSchema)] pub struct NetworkState { pub devices: Vec, pub connections: Vec, @@ -370,7 +370,7 @@ mod tests { } /// Network device -#[derive(Debug, Clone, Serialize)] +#[derive(Debug, Clone, Serialize, utoipa::ToSchema)] pub struct Device { pub name: String, #[serde(rename = "type")] @@ -380,7 +380,7 @@ pub struct Device { /// Represents an availble network connection. #[serde_as] #[skip_serializing_none] -#[derive(Debug, Clone, PartialEq, Serialize)] +#[derive(Debug, Clone, PartialEq, Serialize, utoipa::ToSchema)] pub struct Connection { pub id: String, pub uuid: Uuid, diff --git a/rust/agama-server/src/web/docs.rs b/rust/agama-server/src/web/docs.rs index 58a1de6aed..0c44f0f3e5 100644 --- a/rust/agama-server/src/web/docs.rs +++ b/rust/agama-server/src/web/docs.rs @@ -3,13 +3,21 @@ use utoipa::OpenApi; #[derive(OpenApi)] #[openapi( info(description = "Agama web API description"), - paths(super::http::ping, crate::l10n::web::locales), + paths( + super::http::ping, + crate::l10n::web::locales, + crate::network::web::devices, + crate::network::web::connections + ), components( schemas(super::http::PingResponse), schemas(crate::l10n::LocaleEntry), schemas(crate::l10n::web::LocaleConfig), schemas(crate::l10n::Keymap), - schemas(crate::l10n::TimezoneEntry) + schemas(crate::l10n::TimezoneEntry), + schemas(crate::network::model::NetworkState), + schemas(crate::network::model::Device), + schemas(crate::network::model::Connection) ) )] pub struct ApiDoc;