From 8e06b225899aea65bd4507fdc0f5d430d61bfce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C4=87kowski?= Date: Sun, 22 Feb 2026 22:15:21 +0100 Subject: [PATCH 1/4] feat: add (De)Serialize to `Html` --- cot-core/src/html.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cot-core/src/html.rs b/cot-core/src/html.rs index bdbd8ce9..2e36eddf 100644 --- a/cot-core/src/html.rs +++ b/cot-core/src/html.rs @@ -54,6 +54,7 @@ use std::fmt::Write; use askama::filters::Escaper; use derive_more::{Deref, Display, From}; +use serde::{Deserialize, Serialize}; /// A type that represents HTML content as a string. /// @@ -65,7 +66,22 @@ use derive_more::{Deref, Display, From}; /// let html = Html::new("
Hello
"); /// assert_eq!(html.as_str(), "
Hello
"); /// ``` -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Deref, From, Display)] +#[derive( + Debug, + Clone, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Default, + Deref, + From, + Display, + Serialize, + Deserialize, +)] +#[serde(transparent)] pub struct Html(pub String); impl Html { From ec7ca12e2146f00051f9af3bb16ee1043b47448f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C4=87kowski?= Date: Sun, 22 Feb 2026 22:24:59 +0100 Subject: [PATCH 2/4] fixes, add JsonSchema --- Cargo.lock | 1 + cot-core/Cargo.toml | 4 +++- cot-core/src/html.rs | 2 ++ cot/Cargo.toml | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 169c4cb7..e1af5da2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -990,6 +990,7 @@ dependencies = [ "http-body", "http-body-util", "indexmap", + "schemars", "serde", "serde_html_form", "serde_json", diff --git a/cot-core/Cargo.toml b/cot-core/Cargo.toml index 65f66383..7cdac6ac 100644 --- a/cot-core/Cargo.toml +++ b/cot-core/Cargo.toml @@ -29,7 +29,8 @@ http-body-util.workspace = true http-body.workspace = true http.workspace = true indexmap.workspace = true -serde.workspace = true +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } serde_html_form = { workspace = true, features = ["de", "std"] } serde_json.workspace = true serde_path_to_error.workspace = true @@ -47,3 +48,4 @@ tokio.workspace = true [features] default = [] json = [] +schemars = ["dep:schemars"] diff --git a/cot-core/src/html.rs b/cot-core/src/html.rs index 2e36eddf..db9504ae 100644 --- a/cot-core/src/html.rs +++ b/cot-core/src/html.rs @@ -54,6 +54,7 @@ use std::fmt::Write; use askama::filters::Escaper; use derive_more::{Deref, Display, From}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; /// A type that represents HTML content as a string. @@ -81,6 +82,7 @@ use serde::{Deserialize, Serialize}; Serialize, Deserialize, )] +#[cfg_attr(feature = "schemars", derive(JsonSchema))] #[serde(transparent)] pub struct Html(pub String); diff --git a/cot/Cargo.toml b/cot/Cargo.toml index f12f86d3..77d49aef 100644 --- a/cot/Cargo.toml +++ b/cot/Cargo.toml @@ -113,7 +113,7 @@ postgres = ["db", "sea-query/backend-postgres", "sea-query-binder/sqlx-postgres" mysql = ["db", "sea-query/backend-mysql", "sea-query-binder/sqlx-mysql", "sqlx/mysql"] redis = ["cache", "dep:deadpool-redis", "dep:redis", "json"] json = ["dep:serde_json", "cot_core/json"] -openapi = ["json", "dep:aide", "dep:schemars"] +openapi = ["json", "cot_core/schemars", "dep:aide", "dep:schemars"] swagger-ui = ["openapi", "dep:swagger-ui-redist"] live-reload = ["dep:tower-livereload"] cache = ["json"] From a822aaf70a9d700ab9a3e4b1939852f1763a8bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C4=87kowski?= Date: Sun, 22 Feb 2026 22:43:34 +0100 Subject: [PATCH 3/4] fix --- cot-core/src/html.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cot-core/src/html.rs b/cot-core/src/html.rs index db9504ae..10d5c2dd 100644 --- a/cot-core/src/html.rs +++ b/cot-core/src/html.rs @@ -54,6 +54,7 @@ use std::fmt::Write; use askama::filters::Escaper; use derive_more::{Deref, Display, From}; +#[cfg(feature = "schemars")] use schemars::JsonSchema; use serde::{Deserialize, Serialize}; From 4c46cb7a468e64446ba44bd35379993be26ca82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ma=C4=87kowski?= Date: Sun, 22 Feb 2026 22:49:15 +0100 Subject: [PATCH 4/4] fix deps --- cot-core/Cargo.toml | 2 +- cot/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cot-core/Cargo.toml b/cot-core/Cargo.toml index 7cdac6ac..847f9713 100644 --- a/cot-core/Cargo.toml +++ b/cot-core/Cargo.toml @@ -29,7 +29,7 @@ http-body-util.workspace = true http-body.workspace = true http.workspace = true indexmap.workspace = true -schemars = { workspace = true, optional = true } +schemars = { workspace = true, optional = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] } serde_html_form = { workspace = true, features = ["de", "std"] } serde_json.workspace = true diff --git a/cot/Cargo.toml b/cot/Cargo.toml index 77d49aef..9e83834b 100644 --- a/cot/Cargo.toml +++ b/cot/Cargo.toml @@ -50,7 +50,7 @@ multer.workspace = true password-auth = { workspace = true, features = ["std", "argon2"] } pin-project-lite.workspace = true redis = { workspace = true, features = ["aio", "tokio-comp"], optional = true } -schemars = { workspace = true, optional = true } +schemars = { workspace = true, optional = true, features = ["derive"] } sea-query = { workspace = true, optional = true } sea-query-binder = { workspace = true, features = ["with-chrono", "runtime-tokio"], optional = true } serde = { workspace = true, features = ["derive"] }