json
: better support for "type" unions (e.g. nullable arrays w/ typed items) (#7863)
* json: better suport for "type" arrays (e.g. `{"type": ["array", "null"], "items": {"type": "string"}}`) * json: add test for type: [array, null] fix * update tests
This commit is contained in:
parent
6777c544bd
commit
9b2f16f805
5 changed files with 62 additions and 3 deletions
|
@ -993,6 +993,31 @@ static void test_json_schema() {
|
|||
}
|
||||
);
|
||||
|
||||
test_schema(
|
||||
"",
|
||||
// Schema
|
||||
R"""(
|
||||
{
|
||||
"type": ["array", "null"],
|
||||
"items": { "type": "string" }
|
||||
}
|
||||
)""",
|
||||
// Passing strings
|
||||
{
|
||||
"null",
|
||||
"[]",
|
||||
"[\"123\"]",
|
||||
"[\"foo\", \"bar\"]",
|
||||
},
|
||||
// Failing strings
|
||||
{
|
||||
"",
|
||||
"[123]",
|
||||
"\"foo\"",
|
||||
"[\"foo\", 42]",
|
||||
}
|
||||
);
|
||||
|
||||
test_schema(
|
||||
"min+max items",
|
||||
// Schema
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue