Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GREsau committed Aug 24, 2024
1 parent 2388014 commit a87ac6b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 40 deletions.
13 changes: 6 additions & 7 deletions schemars/tests/docs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod util;
use schemars::{generate::SchemaSettings, JsonSchema};
use schemars::JsonSchema;
use util::*;

#[allow(dead_code)]
Expand All @@ -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
Expand Down Expand Up @@ -57,12 +60,6 @@ fn doc_comments_struct() -> TestResult {
test_default_generated_schema::<MyStruct>("doc_comments_struct")
}

#[test]
fn doc_comments_struct_ref_siblings() -> TestResult {
let settings = SchemaSettings::draft2019_09();
test_generated_schema::<MyStruct>("doc_comments_struct_ref_siblings", settings)
}

#[test]
fn doc_comments_enum() -> TestResult {
test_default_generated_schema::<MyEnum>("doc_comments_enum")
Expand All @@ -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]
Expand Down
8 changes: 7 additions & 1 deletion schemars/tests/expected/doc_comments_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
8 changes: 7 additions & 1 deletion schemars/tests/expected/doc_comments_struct.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
31 changes: 0 additions & 31 deletions schemars/tests/expected/doc_comments_struct_ref_siblings.json

This file was deleted.

0 comments on commit a87ac6b

Please sign in to comment.