| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| let config_toml = toml_edit::ser::to_string_pretty(&self.config)?; | ||
| let contents = | ||
| format!("\"$schema\" = \"https://forgecode.dev/schema.json\"\n\n{config_toml}"); |
There was a problem hiding this comment.
The $schema key is a JSON Schema convention that is not recognized by TOML parsers or editors. While the code successfully writes "$schema" = "https://forgecode.dev/schema.json" as a valid TOML key-value pair, this will not enable IDE validation, auto-complete, or inline documentation as described in the PR. Modern editors only recognize $schema for JSON files, not TOML files. The schema file forge.schema.json is a JSON Schema designed for JSON, but the config file being written is TOML format (using toml_edit::ser::to_string_pretty).
To fix this, either:
| let config_toml = toml_edit::ser::to_string_pretty(&self.config)?; | |
| let contents = | |
| format!("\"$schema\" = \"https://forgecode.dev/schema.json\"\n\n{config_toml}"); | |
| let config_json = serde_json::to_string_pretty(&self.config)?; | |
| let mut schema_obj: serde_json::Value = serde_json::from_str(&config_json)?; | |
| if let serde_json::Value::Object(ref mut map) = schema_obj { | |
| map.insert( | |
| "$schema".to_string(), | |
| serde_json::Value::String("https://forgecode.dev/schema.json".to_string()), | |
| ); | |
| } | |
| let contents = serde_json::to_string_pretty(&schema_obj)?; |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Automatically inject a $schema key into generated Forge config files, enabling real-time editor validation and IntelliSense auto-complete for all configuration fields.
Context
Forge generates a TOML config file (forge.yaml / forge.default.yaml) that users edit by hand, but editors had no way to validate its fields or offer completions. The project already ships a forge.schema.json, but nothing linked the generated config to that schema. This change wires the two together automatically so every generated config benefits from editor tooling without any manual setup.
As a secondary improvement, the doc comments on every ForgeConfig field and the corresponding description strings in forge.schema.json have been rewritten for accuracy, completeness, and consistent style.
Changes
Key Implementation Details
The schema injection is done at the string level after TOML serialisation, keeping the change minimal and independent of serde or toml_edit internals. The schema URL (https://forgecode.dev/schema.json) is the canonical public location for the schema, so editors that support JSON Schema for TOML (VS Code with Even Better TOML, JetBrains IDEs, Neovim with SchemaStore, etc.) will fetch and apply it automatically.
Use Cases
Testing
Links