Add more info to README
This commit is contained in:
parent
5c307b92fb
commit
792fbbb86e
7 changed files with 182 additions and 91 deletions
19
schemars/examples/main.rs
Normal file
19
schemars/examples/main.rs
Normal 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());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue