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/db.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index 47e907d..a2b2009 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,6 +1,7 @@ use serde::Serialize; use sqlx::{PgPool, postgres::PgPoolOptions, types::{ipnetwork::IpNetwork, mac_address::MacAddress}}; use tracing::{debug, info}; +use utoipa::ToSchema; #[derive(Serialize, Debug)] pub struct Device { @@ -11,6 +12,16 @@ pub struct Device { pub times: Option> } +#[derive(ToSchema)] +#[schema(as = Device)] +pub struct DeviceSchema { + pub id: String, + pub mac: String, + pub broadcast_addr: String, + pub ip: String, + pub times: Option> +} + pub async fn init_db_pool(db_url: &str) -> PgPool { debug!("attempt to connect dbPool to '{}'", db_url); -- cgit v1.2.3