vtcode_config/
schema.rs

1#![cfg(feature = "schema")]
2
3use anyhow::{Context, Result};
4use schemars::{schema::RootSchema, schema_for};
5
6use crate::loader::VTCodeConfig;
7
8/// Generate the JSON Schema describing the `vtcode.toml` configuration surface.
9pub fn vtcode_config_schema() -> RootSchema {
10    schema_for!(VTCodeConfig)
11}
12
13/// Render the configuration schema as a `serde_json::Value` for downstream tooling.
14pub fn vtcode_config_schema_json() -> Result<serde_json::Value> {
15    let schema = vtcode_config_schema();
16    serde_json::to_value(schema).context("failed to serialize vtcode-config schema to JSON value")
17}
18
19/// Render the configuration schema as a pretty-printed JSON string.
20pub fn vtcode_config_schema_pretty() -> Result<String> {
21    let value = vtcode_config_schema_json()?;
22    serde_json::to_string_pretty(&value)
23        .context("failed to serialize vtcode-config schema to pretty JSON string")
24}