Add more info to README

This commit is contained in:
Graham Esau 2019-10-22 22:49:24 +01:00
parent 5c307b92fb
commit 792fbbb86e
7 changed files with 182 additions and 91 deletions

19
schemars/examples/main.rs Normal file
View file

@ -0,0 +1,19 @@
use schemars::{schema_for, JsonSchema};
#[derive(JsonSchema)]
pub struct MyStruct {
pub my_int: i32,
pub my_bool: bool,
pub my_nullable_enum: Option<MyEnum>,
}
#[derive(JsonSchema)]
pub enum MyEnum {
Unit,
StringNewType(String)
}
fn main() {
let schema = schema_for!(MyStruct);
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
}