Update test-grammar-integration.cpp
This commit is contained in:
parent
9c05bd26fb
commit
7f227d279d
1 changed files with 25 additions and 28 deletions
|
@ -1303,44 +1303,41 @@ static void test_json_schema() {
|
||||||
);
|
);
|
||||||
|
|
||||||
test_schema(
|
test_schema(
|
||||||
"refs",
|
"nested refs + mix of properties and allOf",
|
||||||
// Schema
|
// Schema
|
||||||
R"""({
|
R"""({
|
||||||
"type": "array",
|
"properties": {
|
||||||
"minItems": 1,
|
"common": {"$ref": "#/$defs/SomeVal"}
|
||||||
"maxItems": 15,
|
},
|
||||||
"items": { "$ref": "#/$defs/TALK" },
|
"allOf": [
|
||||||
|
{"$ref": "#/$defs/foo"},
|
||||||
"$defs": {
|
{"$ref": "#/$defs/bar"},
|
||||||
"characters": { "enum": ["Biff", "Alice"] },
|
{
|
||||||
"emotes": { "enum": ["EXCLAMATION", "CONFUSION", "CHEERFUL", "LOVE", "ANGRY"] },
|
"anyOf": [
|
||||||
|
{"$ref": "#/$defs/baz"},
|
||||||
"TALK": {
|
{"$ref": "#/$defs/bam"}
|
||||||
"type": "object",
|
]
|
||||||
"required": [ "character", "emote", "dialog" ],
|
|
||||||
"properties": {
|
|
||||||
"character": { "$ref": "#/$defs/characters" },
|
|
||||||
"emote": { "$ref": "#/$defs/emotes" },
|
|
||||||
"dialog": {
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1,
|
|
||||||
"maxLength": 200
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"required": ["common"],
|
||||||
|
"$defs": {
|
||||||
|
"SomeVal": {"type": "number"},
|
||||||
|
"foo": {"properties": {"a": {"$ref": "#/$defs/SomeVal"}}},
|
||||||
|
"bar": {"properties": {"b": {"$ref": "#/$defs/SomeVal"}}},
|
||||||
|
"bam": {"properties": {"c": {"$ref": "#/$defs/SomeVal"}}},
|
||||||
|
"baz": {"properties": {"d": {"$ref": "#/$defs/SomeVal"}}}
|
||||||
}
|
}
|
||||||
})""",
|
})""",
|
||||||
// Passing strings
|
// Passing strings
|
||||||
{
|
{
|
||||||
R"""([{
|
R"""({"common": "", "a": "", "b": ""})""",
|
||||||
"character": "Alice",
|
R"""({"common": "", "a": "", "b": "", "d": "", "c": ""})""",
|
||||||
"emote": "EXCLAMATION",
|
|
||||||
"dialog": "Hello, world!"
|
|
||||||
}])""",
|
|
||||||
},
|
},
|
||||||
// Failing strings
|
// Failing strings
|
||||||
{
|
{
|
||||||
|
R"""({})""",
|
||||||
|
R"""({"a": "", "b": ""})""",
|
||||||
|
R"""({"common": "", "a": "", "b": "", "c": "", "d": ""})""",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue