diff --git a/backend/src/lib.rs b/backend/src/lib.rs index a6e3b85b..98eab722 100644 --- a/backend/src/lib.rs +++ b/backend/src/lib.rs @@ -15,6 +15,9 @@ pub mod services; #[cfg_attr(feature = "swagger", derive(OpenApi))] #[cfg_attr(feature = "swagger", openapi( paths(root, services::auth::login, services::auth::logout), + components( + schemas(models::shared::Credentials, models::shared::HostnameApi, models::shared::BobConnectionData) + ), tags( (name = "bob", description = "BOB management API") ) diff --git a/backend/src/models/shared.rs b/backend/src/models/shared.rs index c0dbf02a..6cbca801 100644 --- a/backend/src/models/shared.rs +++ b/backend/src/models/shared.rs @@ -7,6 +7,10 @@ use utoipa::{IntoParams, ToSchema}; #[derive(Display, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] pub struct Hostname(String); +#[derive(ToSchema)] +#[schema(as = Hostname)] +pub struct HostnameApi(String); + impl Hostname { /// Can be safely unwraped thanks to regex #[must_use] @@ -40,9 +44,9 @@ impl TryFrom for SocketAddr { /// Data needed to connect to a BOB cluster #[derive( - IntoParams, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, + IntoParams, ToSchema, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, )] -// #[schema(example = json!({"hostname": "0.0.0.0:7000", "credentials": {"login": "archeoss", "password": "12345"}}))] +#[schema(example = json!({"hostname": "0.0.0.0:7000", "credentials": {"login": "archeoss", "password": "12345"}}))] pub struct BobConnectionData { /// Address to connect to pub hostname: Hostname, diff --git a/backend/src/services/auth.rs b/backend/src/services/auth.rs index e1a45be8..02fa488b 100644 --- a/backend/src/services/auth.rs +++ b/backend/src/services/auth.rs @@ -116,7 +116,7 @@ pub async fn login( Ok(res) } -/// Logout from a BOB cluster/ +/// Logout from a BOB cluster #[cfg_attr(feature = "swagger", utoipa::path( post, context_path = ApiV1::to_path(), @@ -127,11 +127,11 @@ pub async fn login( ))] pub async fn logout( mut auth: AuthContext, -) -> AxumResult { +) -> StatusCode { tracing::info!("get /logout : {:?}", &auth.current_user); auth.logout().await; - Ok(StatusCode::OK) + StatusCode::OK } /// An ephemeral in-memory store, since we don't need to store any users.