| 1 | use schemarsrust-analyzer cargo schemars 1.2.2 crate/::schema_for_valuerust-analyzer cargo schemars 1.2.2 macros/schema_for_value!; |
| 2 | use serderust-analyzer cargo serde 1.0.229 crate/::Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 5 | pub struct MyStructrust-analyzer cargo schemars 1.2.2 MyStruct# { |
| 6 | pub my_intrust-analyzer cargo schemars 1.2.2 MyStruct#my_int.: i32, |
| 7 | pub my_boolrust-analyzer cargo schemars 1.2.2 MyStruct#my_bool.: bool, |
| 8 | 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#>, |
| 9 | } |
| 10 | |
| 11 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 12 | pub enum MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum# { |
| 13 | StringNewTyperust-analyzer cargo schemars 1.2.2 MyEnum#StringNewType#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 14 | 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> }, |
| 15 | } |
| 16 | |
| 17 | fn mainrust-analyzer cargo schemars 1.2.2 main().() { |
| 18 | let schema = schema_for_valuerust-analyzer cargo schemars 1.2.2 macros/schema_for_value!!(MyStructrust-analyzer cargo schemars 1.2.2 MyStruct# { |
| 19 | my_intrust-analyzer cargo schemars 1.2.2 MyStruct#my_int.: 123, |
| 20 | my_boolrust-analyzer cargo schemars 1.2.2 MyStruct#my_bool.: true, |
| 21 | my_nullable_enumrust-analyzer cargo schemars 1.2.2 MyStruct#my_nullable_enum.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum#::StringNewTyperust-analyzer cargo schemars 1.2.2 MyEnum#StringNewType#("foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 22 | }); |
| 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 | } |