Small refactor

This commit is contained in:
Graham Esau 2019-12-29 18:45:55 +00:00
parent 0198ede4b6
commit 1605a8a34d
2 changed files with 20 additions and 26 deletions

View file

@ -8,19 +8,16 @@ pub struct MyStruct {
}
#[derive(JsonSchema)]
pub enum MyEnum {
pub enum MyEnum {
StringNewType(String),
StructVariant {
floats: Vec<f32>,
}
StructVariant { floats: Vec<f32> },
}
fn main() {
let settings = SchemaSettings {
option_nullable: true,
option_add_null_type: false,
..SchemaSettings::draft07()
};
let settings = SchemaSettings::draft07().with(|s| {
s.option_nullable = true;
s.option_add_null_type = false;
});
let gen = settings.into_generator();
let schema = gen.into_root_schema_for::<MyStruct>();
println!("{}", serde_json::to_string_pretty(&schema).unwrap());