diff --git a/rust/agama-lib/Cargo.toml b/rust/agama-lib/Cargo.toml index 5ef8166609..40702e2fde 100644 --- a/rust/agama-lib/Cargo.toml +++ b/rust/agama-lib/Cargo.toml @@ -21,4 +21,5 @@ thiserror = "1.0.39" tokio = { version = "1.33.0", features = ["macros", "rt-multi-thread"] } tokio-stream = "0.1.14" url = "2.5.0" +utoipa = "4.2.0" zbus = { version = "3", default-features = false, features = ["tokio"] } diff --git a/rust/agama-lib/src/network/types.rs b/rust/agama-lib/src/network/types.rs index cb8f9695c8..6caf9549eb 100644 --- a/rust/agama-lib/src/network/types.rs +++ b/rust/agama-lib/src/network/types.rs @@ -4,7 +4,8 @@ use thiserror::Error; use zbus; /// Network device -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "type")] pub struct Device { pub name: String, pub type_: DeviceType, @@ -31,7 +32,7 @@ impl From for Vec { } } -#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub enum DeviceType { Loopback = 0, Ethernet = 1, diff --git a/rust/agama-server/src/network/model.rs b/rust/agama-server/src/network/model.rs index 4ff3d7392e..18bddf85c0 100644 --- a/rust/agama-server/src/network/model.rs +++ b/rust/agama-server/src/network/model.rs @@ -377,7 +377,7 @@ pub struct Device { pub type_: DeviceType, } -/// Represents an availble network connection. +/// Represents a known network connection. #[serde_as] #[skip_serializing_none] #[derive(Debug, Clone, PartialEq, Serialize, utoipa::ToSchema)] diff --git a/rust/agama-server/src/web/docs.rs b/rust/agama-server/src/web/docs.rs index 0c44f0f3e5..e96d4b99bd 100644 --- a/rust/agama-server/src/web/docs.rs +++ b/rust/agama-server/src/web/docs.rs @@ -17,7 +17,8 @@ use utoipa::OpenApi; schemas(crate::l10n::TimezoneEntry), schemas(crate::network::model::NetworkState), schemas(crate::network::model::Device), - schemas(crate::network::model::Connection) + schemas(crate::network::model::Connection), + schemas(agama_lib::network::types::DeviceType) ) )] pub struct ApiDoc;