Add support for indexmap v2
This commit is contained in:
parent
5dbfa49c5e
commit
aeb989486e
4 changed files with 31 additions and 0 deletions
|
@ -21,6 +21,7 @@ dyn-clone = "1.0"
|
||||||
|
|
||||||
chrono = { version = "0.4", default-features = false, optional = true }
|
chrono = { version = "0.4", default-features = false, optional = true }
|
||||||
indexmap = { version = "1.2", features = ["serde-1"], optional = true }
|
indexmap = { version = "1.2", features = ["serde-1"], optional = true }
|
||||||
|
indexmap2 = { version = "2.0", features = ["serde"], optional = true, package = "indexmap" }
|
||||||
either = { version = "1.3", default-features = false, optional = true }
|
either = { version = "1.3", default-features = false, optional = true }
|
||||||
uuid08 = { version = "0.8", default-features = false, optional = true, package = "uuid" }
|
uuid08 = { version = "0.8", default-features = false, optional = true, package = "uuid" }
|
||||||
uuid1 = { version = "1.0", default-features = false, optional = true, package = "uuid" }
|
uuid1 = { version = "1.0", default-features = false, optional = true, package = "uuid" }
|
||||||
|
@ -69,6 +70,10 @@ required-features = ["chrono"]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
required-features = ["indexmap"]
|
required-features = ["indexmap"]
|
||||||
|
|
||||||
|
[[test]]
|
||||||
|
name = "indexmap2"
|
||||||
|
required-features = ["indexmap2"]
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "either"
|
name = "either"
|
||||||
required-features = ["either"]
|
required-features = ["either"]
|
||||||
|
|
8
schemars/src/json_schema_impls/indexmap2.rs
Normal file
8
schemars/src/json_schema_impls/indexmap2.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
use crate::gen::SchemaGenerator;
|
||||||
|
use crate::schema::*;
|
||||||
|
use crate::JsonSchema;
|
||||||
|
use indexmap2::{IndexMap, IndexSet};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
forward_impl!((<K, V: JsonSchema, H> JsonSchema for IndexMap<K, V, H>) => HashMap<K, V, H>);
|
||||||
|
forward_impl!((<T: JsonSchema, H> JsonSchema for IndexSet<T, H>) => HashSet<T, H>);
|
|
@ -56,6 +56,8 @@ mod enumset;
|
||||||
mod ffi;
|
mod ffi;
|
||||||
#[cfg(feature = "indexmap")]
|
#[cfg(feature = "indexmap")]
|
||||||
mod indexmap;
|
mod indexmap;
|
||||||
|
#[cfg(feature = "indexmap2")]
|
||||||
|
mod indexmap2;
|
||||||
mod maps;
|
mod maps;
|
||||||
mod nonzero_signed;
|
mod nonzero_signed;
|
||||||
mod nonzero_unsigned;
|
mod nonzero_unsigned;
|
||||||
|
|
16
schemars/tests/indexmap2.rs
Normal file
16
schemars/tests/indexmap2.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
mod util;
|
||||||
|
use indexmap2::{IndexMap, IndexSet};
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use util::*;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(JsonSchema)]
|
||||||
|
struct IndexMapTypes {
|
||||||
|
map: IndexMap<i32, bool>,
|
||||||
|
set: IndexSet<isize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn indexmap_types() -> TestResult {
|
||||||
|
test_default_generated_schema::<IndexMapTypes>("indexmap")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue