Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion cot-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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, features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
serde_html_form = { workspace = true, features = ["de", "std"] }
serde_json.workspace = true
serde_path_to_error.workspace = true
Expand All @@ -47,3 +48,4 @@ tokio.workspace = true
[features]
default = []
json = []
schemars = ["dep:schemars"]
21 changes: 20 additions & 1 deletion cot-core/src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ use std::fmt::Write;

use askama::filters::Escaper;
use derive_more::{Deref, Display, From};
#[cfg(feature = "schemars")]
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// A type that represents HTML content as a string.
///
Expand All @@ -65,7 +68,23 @@ use derive_more::{Deref, Display, From};
/// let html = Html::new("<div>Hello</div>");
/// assert_eq!(html.as_str(), "<div>Hello</div>");
/// ```
#[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,
)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(transparent)]
pub struct Html(pub String);

impl Html {
Expand Down
4 changes: 2 additions & 2 deletions cot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down Expand Up @@ -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"]
Expand Down
Loading