Skip to content

Commit 25cb722

Browse files
committed
add support for compact_str crate
1 parent e0c2c31 commit 25cb722

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed

Cargo.lock

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schemars/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bigdecimal03 = { version = "0.3", default-features = false, optional = true, pac
3535
bigdecimal04 = { version = "0.4", default-features = false, optional = true, package = "bigdecimal" }
3636
enumset = { version = "1.0", optional = true }
3737
smol_str = { version = "0.1.17", optional = true }
38+
compact_str = { version = "0.8.0", optional = true }
3839
semver = { version = "1.0.9", features = ["serde"], optional = true }
3940

4041
[dev-dependencies]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use crate::gen::SchemaGenerator;
2+
use crate::schema::*;
3+
use crate::JsonSchema;
4+
use compact_str::CompactString;
5+
6+
forward_impl!(CompactString => String);

schemars/src/json_schema_impls/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ mod atomic;
5050
mod bytes;
5151
#[cfg(feature = "chrono")]
5252
mod chrono;
53+
#[cfg(feature = "compact_str")]
54+
mod compact_str;
5355
mod core;
5456
#[cfg(any(
5557
feature = "rust_decimal",

schemars/tests/compact_str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
mod util;
2+
use compact_str::CompactString;
3+
use util::*;
4+
5+
#[test]
6+
fn smol_str() -> TestResult {
7+
test_default_generated_schema::<CompactString>("compact_str")
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "String",
4+
"type": "string"
5+
}

0 commit comments

Comments
 (0)