add optional smol_str support (#72)

Co-authored-by: Graham Esau <gesau@hotmail.co.uk>
This commit is contained in:
Gleb Pomykalov 2023-02-26 19:42:16 +00:00 committed by GitHub
parent 73715c10e0
commit 587176fe9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 0 deletions

View file

@ -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

View file

@ -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")]

View file

@ -0,0 +1,6 @@
use crate::gen::SchemaGenerator;
use crate::schema::*;
use crate::JsonSchema;
use smol_str::SmolStr;
forward_impl!(SmolStr => String);

View file

@ -0,0 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "String",
"type": "string"
}

View 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")
}