jsonschema-annotator
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.
Example
Given a schema:
And a config:
[]
= 8080
Produces:
# Server Configuration
# HTTP server settings
[]
# Port
# The port number to listen on
= 8080
Installation
Or build from source:
CLI Usage
# Annotate a TOML file, output to stdout
# Annotate a YAML file, write to output file
# Read from stdin (defaults to YAML format)
|
# Only include titles (no descriptions)
# Custom line width for description wrapping
CLI Options
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
Library Usage
use ;
use Schema;
let schema_json = r#"{
"properties": {
"port": {
"title": "Port",
"description": "Server port number"
}
}
}"#;
let schema: Schema = from_str.unwrap;
let config_str = "port = 8080";
let annotated = annotate.unwrap;
assert!;
assert!;
Configuration Options
let config = AnnotatorConfig ;
Features
- 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
Limitations
- Only local
$ref(starting with#) are supported; external file/URL references are not - YAML inline tables and complex structures may not be annotated
License
MIT License - see LICENSE for details.