Add private field to SchemaSettings to prevent struct initialization.

This means future additions to SchemaSettings will not be breaking changes.
This commit is contained in:
Graham Esau 2019-12-29 14:45:23 +00:00
parent 1963b5c715
commit 233b1a4165
4 changed files with 41 additions and 27 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());