use crate::prelude::*;
#[allow(dead_code)]
#[derive(JsonSchema)]
struct MyStruct {
my_int: i32,
my_undocumented_bool: bool,
my_unit: MyUnitStruct,
#[doc = concat!("# Documented ", "bool")]
#[doc = concat!("This bool is documented")]
my_documented_bool: bool,
}
#[derive(JsonSchema)]
struct MyUnitStruct;
#[test]
fn doc_comments_struct() {
test!(MyStruct).assert_snapshot();
}
#[allow(dead_code)]
#[doc = " # This is the enum's title "]
#[doc = " This is "]
#[derive(JsonSchema)]
#[doc = " the enum's description."]
enum MyEnum {
UndocumentedUnit,
UndocumentedUnit2,
DocumentedUnit,
Complex {
my_nullable_string: Option<String>,
},
}
#[test]
fn doc_comments_enum() {
test!(MyEnum).assert_snapshot();
}
#[allow(dead_code)]
#[derive(JsonSchema)]
#[schemars(description = "New description")]
struct OverrideDocs {
#[schemars(title = "My integer", description = "This is an i32")]
my_int: i32,
#[schemars(title = "", description = "")]
my_undocumented_bool: bool,
#[schemars(title = concat!("Documented ", "bool"), description = "Capitalized".to_uppercase())]
my_documented_bool: bool,
}
#[test]
fn doc_comments_override() {
test!(OverrideDocs).assert_snapshot();
}