Skip to main content

vtcode_config/
schema.rs

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