| Crates.io | jsonschema-annotator |
| lib.rs | jsonschema-annotator |
| version | 0.2.0 |
| created_at | 2025-12-19 10:12:39.006866+00 |
| updated_at | 2025-12-19 10:56:02.313931+00 |
| description | Annotate YAML and TOML configuration files with comments from JSON Schema |
| homepage | |
| repository | https://github.com/kellpossible/jsonschema-annotator |
| max_upload_size | |
| id | 1994505 |
| size | 122,473 |
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 = 8080
Produces:
# Server Configuration
# HTTP server settings
[server]
# Port
# The port number to listen on
port = 8080
cargo install jsonschema-annotator
Or 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 60
Options:
-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
};
$ref pointers are resolved automaticallyoneOf, allOf, and anyOf are supportedtoml_edit and string-based YAML injection to preserve formatting$ref (starting with #) are supported; external file/URL references are notMIT License - see LICENSE for details.