Add test for allow_ref_siblings behaviour
This commit is contained in:
parent
58cc7fac25
commit
6bebd73701
2 changed files with 38 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
mod util;
|
||||
use schemars::JsonSchema;
|
||||
use schemars::{gen::SchemaSettings, JsonSchema};
|
||||
use util::*;
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
|
@ -56,6 +56,12 @@ fn doc_comments_struct() -> TestResult {
|
|||
test_default_generated_schema::<MyStruct>("doc_comments_struct")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_comments_struct_ref_siblings() -> TestResult {
|
||||
let settings = SchemaSettings::draft07().with(|s| s.allow_ref_siblings = true);
|
||||
test_generated_schema::<MyStruct>("doc_comments_struct_ref_siblings", settings)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doc_comments_enum() -> TestResult {
|
||||
test_default_generated_schema::<MyEnum>("doc_comments_enum")
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "This is the struct's title",
|
||||
"description": "This is the struct's description.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"my_int",
|
||||
"my_undocumented_bool",
|
||||
"my_unit"
|
||||
],
|
||||
"properties": {
|
||||
"my_int": {
|
||||
"title": "An integer",
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"my_undocumented_bool": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"my_unit": {
|
||||
"description": "A unit struct instance",
|
||||
"$ref": "#/definitions/MyUnitStruct"
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"MyUnitStruct": {
|
||||
"title": "A Unit",
|
||||
"type": "null"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue