Add test for flattened structs (currently ignored)
This commit is contained in:
parent
933eb1ac40
commit
2aa1835240
1 changed files with 37 additions and 0 deletions
37
schemars/tests/flatten.rs
Normal file
37
schemars/tests/flatten.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use schemars::{schema_for, MakeSchema};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, MakeSchema)]
|
||||||
|
struct Flat {
|
||||||
|
foo: f32,
|
||||||
|
bar: bool,
|
||||||
|
baz: String,
|
||||||
|
foobar: Vec<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, MakeSchema)]
|
||||||
|
struct Deep1 {
|
||||||
|
foo: f32,
|
||||||
|
#[serde(flatten)]
|
||||||
|
deep2: Deep2,
|
||||||
|
foobar: Vec<i32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, MakeSchema)]
|
||||||
|
struct Deep2 {
|
||||||
|
bar: bool,
|
||||||
|
#[serde(flatten)]
|
||||||
|
deep3: Deep3,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, PartialEq, MakeSchema)]
|
||||||
|
struct Deep3 {
|
||||||
|
baz: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "flattening is not yet implemented"]
|
||||||
|
fn flatten_schema() {
|
||||||
|
assert_eq!(schema_for!(Flat), schema_for!(Deep1));
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue