Skip to main content

inspect

Function inspect 

Source
pub fn inspect(
    registry: &CapabilityRegistry,
    tree: &CommandDoc,
    openapi: &Value,
) -> (OperationParity, Vec<Violation>)
Expand description

Measure the registry against its projections, and against the command line.

openapi is the generated document; parity asserts that every capability declaring an HTTP route is described by it, which is what makes Swagger UI and every generated client a reading of the registry rather than of a hand-kept file.

use majordomus_cli::{cli, quality::parity};
use majordomus_cli::capability::CapabilityRegistry;
use serde_json::json;

// an empty registry, an empty document: the command line is then the whole finding set
let registry = CapabilityRegistry::builder().build().unwrap();
let (counts, findings) = parity::inspect(&registry, &cli::tree(), &json!({"paths": {}}));
assert_eq!(counts.canonical, 0);
assert!(counts.cli_commands > 0, "the command line has commands regardless");
assert!(!findings.is_empty(), "every command is then unaccounted for");