docs(config): document schema command and add schema test

This commit is contained in:
Chummy 2026-02-19 16:38:05 +08:00
parent 282fbe0e95
commit d33eadea75
3 changed files with 45 additions and 2 deletions

View file

@ -3104,6 +3104,38 @@ mod tests {
assert!(c.config_path.to_string_lossy().contains("config.toml"));
}
#[test]
fn config_schema_export_contains_expected_contract_shape() {
let schema = schemars::schema_for!(Config);
let schema_json = serde_json::to_value(&schema).expect("schema should serialize to json");
assert_eq!(
schema_json
.get("$schema")
.and_then(serde_json::Value::as_str),
Some("https://json-schema.org/draft/2020-12/schema")
);
let properties = schema_json
.get("properties")
.and_then(serde_json::Value::as_object)
.expect("schema should expose top-level properties");
assert!(properties.contains_key("default_provider"));
assert!(properties.contains_key("gateway"));
assert!(properties.contains_key("channels_config"));
assert!(!properties.contains_key("workspace_dir"));
assert!(!properties.contains_key("config_path"));
assert!(
schema_json
.get("$defs")
.and_then(serde_json::Value::as_object)
.is_some(),
"schema should include reusable type definitions"
);
}
#[test]
fn observability_config_default() {
let o = ObservabilityConfig::default();