Add schema_for
macro
This commit is contained in:
parent
463ba518b6
commit
ef5c584118
4 changed files with 14 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
use schemars::gen::SchemaGenerator;
|
||||
use schemars::schema::*;
|
||||
use schemars::schema_for;
|
||||
use serde_json::{from_str, to_string_pretty};
|
||||
use std::fs;
|
||||
|
||||
|
@ -12,8 +12,7 @@ mod tests {
|
|||
let expected_json = fs::read_to_string("tests/schema.json")?;
|
||||
let expected: Schema = from_str(&expected_json)?;
|
||||
|
||||
let gen = SchemaGenerator::new();
|
||||
let actual = gen.into_root_schema_for::<Schema>();
|
||||
let actual = schema_for!(Schema);
|
||||
fs::write("tests/schema.actual.json", to_string_pretty(&actual)?)?;
|
||||
|
||||
assert_eq!(actual, expected, "\n\nGenerated schema did not match saved schema - generated schema has been written to \"tests/schema.actual.json\".");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue