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:
parent
b6e54ae2f1
commit
e5bc0486b5
7 changed files with 75 additions and 45 deletions
18
crates/schema_generator/Cargo.toml
Normal file
18
crates/schema_generator/Cargo.toml
Normal 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
|
1
crates/schema_generator/LICENSE-GPL
Symbolic link
1
crates/schema_generator/LICENSE-GPL
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../LICENSE-GPL
|
26
crates/schema_generator/src/main.rs
Normal file
26
crates/schema_generator/src/main.rs
Normal 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(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue