Debian Codegraph @

examples/custom_settings.rs

raw symbols SCIP
1 use schemarsrust-analyzer cargo schemars 1.2.2 crate/::{generaterust-analyzer cargo schemars 1.2.2 generate/::SchemaSettingsrust-analyzer cargo schemars 1.2.2 generate/SchemaSettings#, JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema#};
2
3 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
4 pub struct MyStructrust-analyzer cargo schemars 1.2.2 MyStruct# {
5 pub my_intrust-analyzer cargo schemars 1.2.2 MyStruct#my_int.: i32,
6 pub my_boolrust-analyzer cargo schemars 1.2.2 MyStruct#my_bool.: bool,
7 pub my_nullable_enumrust-analyzer cargo schemars 1.2.2 MyStruct#my_nullable_enum.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum#>,
8 }
9
10 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
11 pub enum MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum# {
12 StringNewTyperust-analyzer cargo schemars 1.2.2 MyEnum#StringNewType#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
13 StructVariantrust-analyzer cargo schemars 1.2.2 MyEnum#StructVariant# { floatsrust-analyzer cargo schemars 1.2.2 MyEnum#StructVariant#floats.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f32> },
14 }
15
16 fn mainrust-analyzer cargo schemars 1.2.2 main().() {
17 let settings = SchemaSettingsrust-analyzer cargo schemars 1.2.2 generate/SchemaSettings#::draft07rust-analyzer cargo schemars 1.2.2 generate/impl#[SchemaSettings]draft07().().withrust-analyzer cargo schemars 1.2.2 generate/impl#[SchemaSettings]with().(|s| {
18 s.meta_schemarust-analyzer cargo schemars 1.2.2 generate/SchemaSettings#meta_schema. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
19 s.inline_subschemasrust-analyzer cargo schemars 1.2.2 generate/SchemaSettings#inline_subschemas. = true;
20 });
21 let generator = settings.into_generatorrust-analyzer cargo schemars 1.2.2 generate/impl#[SchemaSettings]into_generator().();
22 let schema = generator.into_root_schema_forrust-analyzer cargo schemars 1.2.2 generate/impl#[SchemaGenerator]into_root_schema_for().::<MyStructrust-analyzer cargo schemars 1.2.2 MyStruct#>();
23 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_string_prettyrust-analyzer cargo serde_json 1.0.151 ser/to_string_pretty().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
24 }