pub fn allow_lines(schema: &Value) -> Vec<String>Expand description
The allow-list a JSON Schema derives: one anchored pattern per key path the schema
allows, in the schema’s order, as the shell tool’s mj_yaml_unknown_keys reads them
(grep -E -f). A list of scalars is name(\.[0-9]+)?, a list of objects recurses
through name\.[0-9]+\., a nested object through name\.. Local $refs into
$defs are followed. No blank lines and no comments: every line is a pattern.
use majordomus_cli::generate::allow_lines;
use serde_json::json;
let schema = json!({ "type": "object", "properties": {
"id": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } },
"x-majordomus": { "type": "object", "properties": { "tests": { "type": "array", "items": { "type": "string" } } } }
} });
assert_eq!(allow_lines(&schema), [
"^id$",
"^tags(\\.[0-9]+)?$",
"^x-majordomus\\.tests(\\.[0-9]+)?$",
]);