add optional smol_str support (#72)
Co-authored-by: Graham Esau <gesau@hotmail.co.uk>
This commit is contained in:
parent
73715c10e0
commit
587176fe9f
5 changed files with 26 additions and 0 deletions
|
@ -31,6 +31,7 @@ bytes = { version = "1.0", optional = true }
|
|||
rust_decimal = { version = "1", default-features = false, optional = true }
|
||||
bigdecimal = { version = "0.3", default-features = false, optional = true }
|
||||
enumset = { version = "1.0", optional = true }
|
||||
smol_str = { version = "0.1.17", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.2.1"
|
||||
|
@ -102,5 +103,9 @@ required-features = ["url"]
|
|||
name = "enumset"
|
||||
required-features = ["enumset"]
|
||||
|
||||
[[test]]
|
||||
name = "smol_str"
|
||||
required-features = ["smol_str"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
|
|
@ -64,6 +64,8 @@ mod sequences;
|
|||
mod serdejson;
|
||||
#[cfg(feature = "smallvec")]
|
||||
mod smallvec;
|
||||
#[cfg(feature = "smol_str")]
|
||||
mod smol_str;
|
||||
mod time;
|
||||
mod tuple;
|
||||
#[cfg(feature = "url")]
|
||||
|
|
6
schemars/src/json_schema_impls/smol_str.rs
Normal file
6
schemars/src/json_schema_impls/smol_str.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use crate::gen::SchemaGenerator;
|
||||
use crate::schema::*;
|
||||
use crate::JsonSchema;
|
||||
use smol_str::SmolStr;
|
||||
|
||||
forward_impl!(SmolStr => String);
|
5
schemars/tests/expected/smol_str.json
Normal file
5
schemars/tests/expected/smol_str.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "String",
|
||||
"type": "string"
|
||||
}
|
8
schemars/tests/smol_str.rs
Normal file
8
schemars/tests/smol_str.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
mod util;
|
||||
use smol_str::SmolStr;
|
||||
use util::*;
|
||||
|
||||
#[test]
|
||||
fn smol_str() -> TestResult {
|
||||
test_default_generated_schema::<SmolStr>("smol_str")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue