| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | |
| 3 | #[allow(dead_code)] |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)] |
| 5 | /** |
| 6 | # This is the struct's title |
| 7 | |
| 8 | This is the struct's description. |
| 9 | */ |
| 10 | struct MyStructrust-analyzer cargo schemars 1.2.2 docs/MyStruct# { |
| 11 | /// # An integer |
| 12 | my_intrust-analyzer cargo schemars 1.2.2 docs/MyStruct#my_int.: i32, |
| 13 | my_undocumented_boolrust-analyzer cargo schemars 1.2.2 docs/MyStruct#my_undocumented_bool.: bool, |
| 14 | /// A unit struct instance |
| 15 | my_unitrust-analyzer cargo schemars 1.2.2 docs/MyStruct#my_unit.: MyUnitStructrust-analyzer cargo schemars 1.2.2 docs/MyUnitStruct#, |
| 16 | #[doc = concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!("# Documented ", "bool")] |
| 17 | #[doc = concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!("This bool is documented")] |
| 18 | my_documented_boolrust-analyzer cargo schemars 1.2.2 docs/MyStruct#my_documented_bool.: bool, |
| 19 | } |
| 20 | |
| 21 | /// # A Unit |
| 22 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)] |
| 23 | struct MyUnitStructrust-analyzer cargo schemars 1.2.2 docs/MyUnitStruct#; |
| 24 | |
| 25 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 26 | fn doc_comments_structrust-analyzer cargo schemars 1.2.2 docs/doc_comments_struct().() { |
| 27 | testrust-analyzer cargo schemars 1.2.2 test!!(MyStructrust-analyzer cargo schemars 1.2.2 docs/MyStruct#).assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().(); |
| 28 | } |
| 29 | |
| 30 | #[allow(dead_code)] |
| 31 | #[doc = " # This is the enum's title "] |
| 32 | #[doc = " This is "] |
| 33 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)] |
| 34 | #[doc = " the enum's description."] |
| 35 | enum MyEnumrust-analyzer cargo schemars 1.2.2 docs/MyEnum# { |
| 36 | UndocumentedUnitrust-analyzer cargo schemars 1.2.2 docs/MyEnum#UndocumentedUnit#, |
| 37 | UndocumentedUnit2rust-analyzer cargo schemars 1.2.2 docs/MyEnum#UndocumentedUnit2#, |
| 38 | /// This comment is included in the generated schema :) |
| 39 | DocumentedUnitrust-analyzer cargo schemars 1.2.2 docs/MyEnum#DocumentedUnit#, |
| 40 | /// ## Complex variant |
| 41 | /// This is a struct-like variant. |
| 42 | Complexrust-analyzer cargo schemars 1.2.2 docs/MyEnum#Complex# { |
| 43 | /// ### A nullable string |
| 44 | /// |
| 45 | /// This field is a nullable string. |
| 46 | /// |
| 47 | /// This |
| 48 | ///is |
| 49 | /// the second |
| 50 | /// line! |
| 51 | /// |
| 52 | /// |
| 53 | /// |
| 54 | /// |
| 55 | /// And this is the third! |
| 56 | my_nullable_stringrust-analyzer cargo schemars 1.2.2 docs/MyEnum#Complex#my_nullable_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 61 | fn doc_comments_enumrust-analyzer cargo schemars 1.2.2 docs/doc_comments_enum().() { |
| 62 | testrust-analyzer cargo schemars 1.2.2 test!!(MyEnumrust-analyzer cargo schemars 1.2.2 docs/MyEnum#).assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().(); |
| 63 | } |
| 64 | |
| 65 | /// # OverrideDocs struct |
| 66 | /// This description should be overridden |
| 67 | #[allow(dead_code)] |
| 68 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)] |
| 69 | #[schemars(description = "New description")] |
| 70 | struct OverrideDocsrust-analyzer cargo schemars 1.2.2 docs/OverrideDocs# { |
| 71 | /// # Overridden |
| 72 | #[schemarsrust-analyzer cargo schemars_derive 1.2.2 schemars:(title = "My integer", description = "This is an i32")] |
| 73 | my_intrust-analyzer cargo schemars 1.2.2 docs/OverrideDocs#my_int.: i32, |
| 74 | /// # Overridden |
| 75 | /// Also overridden |
| 76 | #[schemarsrust-analyzer cargo schemars_derive 1.2.2 schemars:(title = "", description = "")] |
| 77 | my_undocumented_boolrust-analyzer cargo schemars 1.2.2 docs/OverrideDocs#my_undocumented_bool.: bool, |
| 78 | #[schemarsrust-analyzer cargo schemars_derive 1.2.2 schemars:(title = concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!("Documented ", "bool"), description = "Capitalized".to_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_uppercase().())] |
| 79 | my_documented_boolrust-analyzer cargo schemars 1.2.2 docs/OverrideDocs#my_documented_bool.: bool, |
| 80 | } |
| 81 | |
| 82 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 83 | fn doc_comments_overriderust-analyzer cargo schemars 1.2.2 docs/doc_comments_override().() { |
| 84 | testrust-analyzer cargo schemars 1.2.2 test!!(OverrideDocsrust-analyzer cargo schemars 1.2.2 docs/OverrideDocs#).assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().(); |
| 85 | } |