Skip to content

Commit

Permalink
Added network openapi documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Mar 5, 2024
1 parent c0a4cab commit 87a1653
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions rust/agama-server/src/network/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Device>,
pub connections: Vec<Connection>,
Expand Down Expand Up @@ -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")]
Expand All @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions rust/agama-server/src/web/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 87a1653

Please sign in to comment.