WARNING: This project was vibe-coded with claude with minimal review, use at your own risk!
Annotate YAML and TOML configuration files with comments derived from JSON Schema title and description fields.
Given a schema:
{
"properties": {
"server": {
"title": "Server Configuration",
"description": "HTTP server settings",
"properties": {
"port": {
"title": "Port",
"description": "The port number to listen on"
}
}
}
}
}And a config:
[server]
port = 8080Produces:
# Server Configuration
# HTTP server settings
[server]
# Port
# The port number to listen on
port = 8080cargo install jsonschema-annotatorOr build from source:
git clone https://github.com/kellpossible/jsonschema-annotator
cd jsonschema-annotator
cargo build --release# Annotate a TOML file, output to stdout
jsonschema-annotator -s schema.json -i config.toml
# Annotate a YAML file, write to output file
jsonschema-annotator -s schema.json -i config.yaml -o config.annotated.yaml
# Read from stdin (defaults to YAML format)
cat config.yaml | jsonschema-annotator -s schema.json -i -
# Only include titles (no descriptions)
jsonschema-annotator -s schema.json -i config.toml --include title
# Custom line width for description wrapping
jsonschema-annotator -s schema.json -i config.toml --max-width 60Options:
-s, --schema <SCHEMA> Path to JSON Schema file (JSON or YAML)
-i, --input <INPUT> Path to config file to annotate (YAML or TOML), or - for stdin
-o, --output <OUTPUT> Output path (default: stdout)
--include <INCLUDE> What to include in comments [default: both] [possible values: title, description, both]
--max-width <MAX_WIDTH> Maximum line width for description wrapping [default: 80]
--force Overwrite output file if it exists
-h, --help Print help
-V, --version Print version
use jsonschema_annotator::{annotate, TargetFormat, AnnotatorConfig};
use schemars::Schema;
let schema_json = r#"{
"properties": {
"port": {
"title": "Port",
"description": "Server port number"
}
}
}"#;
let schema: Schema = serde_json::from_str(schema_json).unwrap();
let config_str = "port = 8080";
let annotated = annotate(
&schema,
config_str,
TargetFormat::Toml,
AnnotatorConfig::default(),
).unwrap();
assert!(annotated.contains("# Port"));
assert!(annotated.contains("# Server port number"));let config = AnnotatorConfig {
include_title: true, // Include schema titles
include_description: true, // Include schema descriptions
max_line_width: Some(80), // Wrap descriptions at 80 chars
preserve_existing: true, // Keep existing comments
};- TOML & YAML support: Annotate both formats with the same schema
- $ref resolution: Local JSON Schema
$refpointers are resolved automatically - Schema composition:
oneOf,allOf, andanyOfare supported - Format preservation: Uses
toml_editand string-based YAML injection to preserve formatting - Configurable output: Include title, description, or both
- Line wrapping: Long descriptions are wrapped at configurable width
- Existing comments: Optionally preserve existing comments in the file
- Only local
$ref(starting with#) are supported; external file/URL references are not - YAML inline tables and complex structures may not be annotated
MIT License - see LICENSE for details.