Add schema_generator for generating JSON schemas (#23991)

This PR adds a `schema_generator` crate that can be used to generate our
various JSON schemas for publishing elsewhere.

Currently it does the simplest thing possible and just prints the JSON
schema to stdout. We can make this a but more robust later.

I also removed the schema-printing facilities from the `theme_importer`,
as they don't really make sense there.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-01-30 20:22:10 -05:00 committed by GitHub
parent b6e54ae2f1
commit e5bc0486b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 75 additions and 45 deletions

View file

@ -0,0 +1,18 @@
[package]
name = "schema_generator"
version = "0.1.0"
publish.workspace = true
edition.workspace = true
license = "GPL-3.0-or-later"
[lints]
workspace = true
[dependencies]
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
env_logger.workspace = true
schemars = { workspace = true, features = ["indexmap2"] }
serde.workspace = true
serde_json.workspace = true
theme.workspace = true

View file

@ -0,0 +1 @@
../../LICENSE-GPL

View file

@ -0,0 +1,26 @@
use anyhow::Result;
use clap::Parser;
use schemars::schema_for;
use theme::{IconThemeFamilyContent, ThemeFamilyContent};
#[derive(Parser, Debug)]
struct Args {}
fn main() -> Result<()> {
env_logger::init();
let _args = Args::parse();
let theme_family_schema = schema_for!(ThemeFamilyContent);
println!("Theme Schema:");
println!("{}", serde_json::to_string_pretty(&theme_family_schema)?);
let icon_theme_family_schema = schema_for!(IconThemeFamilyContent);
println!("Icon Theme Schema:");
println!(
"{}",
serde_json::to_string_pretty(&icon_theme_family_schema)?
);
Ok(())
}