This commit is contained in:
2026-03-02 05:05:33 +01:00
parent 08c1d0c605
commit 6cc6fe6fc7
31 changed files with 1240 additions and 0 deletions

23
crete/src/bin/schemas.rs Normal file
View File

@@ -0,0 +1,23 @@
use std::{fs::File, io::Write};
use crete::{cluster::Cluster, node::OptionalNode};
use repo_path_lib::repo_dir;
use schemars::{JsonSchema, schema_for};
fn write<T>(name: &str)
where
T: JsonSchema,
{
let mut path = repo_dir().join("schemas").join(name);
path.add_extension("json");
let mut file = File::create(path).unwrap();
let schema = serde_json::to_string_pretty(&schema_for!(T)).unwrap();
file.write_all(schema.as_bytes()).unwrap();
}
// TODO: Create directory if it does not exist
fn main() {
write::<Cluster>("cluster");
write::<OptionalNode>("node");
}