diff --git a/schemars/tests/docs.rs b/schemars/tests/docs.rs index c46cb896..86048f24 100644 --- a/schemars/tests/docs.rs +++ b/schemars/tests/docs.rs @@ -15,6 +15,9 @@ struct MyStruct { my_undocumented_bool: bool, /// A unit struct instance my_unit: MyUnitStruct, + #[doc = concat!("# Documented ", "bool")] + #[doc = concat!("This bool is documented")] + my_documented_bool: bool, } /// # A Unit @@ -57,12 +60,6 @@ fn doc_comments_struct() -> TestResult { test_default_generated_schema::("doc_comments_struct") } -#[test] -fn doc_comments_struct_ref_siblings() -> TestResult { - let settings = SchemaSettings::draft2019_09(); - test_generated_schema::("doc_comments_struct_ref_siblings", settings) -} - #[test] fn doc_comments_enum() -> TestResult { test_default_generated_schema::("doc_comments_enum") @@ -81,6 +78,8 @@ struct OverrideDocs { /// Also overridden #[schemars(title = "", description = "")] my_undocumented_bool: bool, + #[schemars(title = concat!("Documented ", "bool"), description = "Capitalized".to_uppercase())] + my_documented_bool: bool, } #[test] diff --git a/schemars/tests/expected/doc_comments_override.json b/schemars/tests/expected/doc_comments_override.json index b184d2a2..00eebe57 100644 --- a/schemars/tests/expected/doc_comments_override.json +++ b/schemars/tests/expected/doc_comments_override.json @@ -12,10 +12,16 @@ }, "my_undocumented_bool": { "type": "boolean" + }, + "my_documented_bool": { + "title": "Documented bool", + "description": "CAPITALIZED", + "type": "boolean" } }, "required": [ "my_int", - "my_undocumented_bool" + "my_undocumented_bool", + "my_documented_bool" ] } \ No newline at end of file diff --git a/schemars/tests/expected/doc_comments_struct.json b/schemars/tests/expected/doc_comments_struct.json index 655121af..caae1386 100644 --- a/schemars/tests/expected/doc_comments_struct.json +++ b/schemars/tests/expected/doc_comments_struct.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft/2019-09/schema", "title": "This is the struct's title", "description": "This is the struct's description.", "type": "object", @@ -15,12 +15,18 @@ "my_unit": { "description": "A unit struct instance", "$ref": "#/$defs/MyUnitStruct" + }, + "my_documented_bool": { + "title": "Documented bool", + "description": "This bool is documented", + "type": "boolean" } }, "required": [ "my_int", "my_undocumented_bool", - "my_unit" + "my_unit", + "my_documented_bool" ], "$defs": { "MyUnitStruct": { diff --git a/schemars/tests/expected/doc_comments_struct_ref_siblings.json b/schemars/tests/expected/doc_comments_struct_ref_siblings.json deleted file mode 100644 index 6b6caebf..00000000 --- a/schemars/tests/expected/doc_comments_struct_ref_siblings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2019-09/schema", - "title": "This is the struct's title", - "description": "This is the struct's description.", - "type": "object", - "properties": { - "my_int": { - "title": "An integer", - "type": "integer", - "format": "int32" - }, - "my_undocumented_bool": { - "type": "boolean" - }, - "my_unit": { - "description": "A unit struct instance", - "$ref": "#/$defs/MyUnitStruct" - } - }, - "required": [ - "my_int", - "my_undocumented_bool", - "my_unit" - ], - "$defs": { - "MyUnitStruct": { - "title": "A Unit", - "type": "null" - } - } -} \ No newline at end of file