25 lines
542 B
Rust
25 lines
542 B
Rust
use std::fs::File;
|
|
use std::io::Write;
|
|
|
|
use crete::cluster::Cluster;
|
|
use crete::node::Node;
|
|
use repo_path::repo_path;
|
|
use schemars::{JsonSchema, schema_for};
|
|
|
|
fn write<T>(name: &str)
|
|
where
|
|
T: JsonSchema,
|
|
{
|
|
let mut path = repo_path!("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();
|
|
}
|
|
|
|
fn main() {
|
|
write::<Cluster>("cluster");
|
|
write::<Node>("node");
|
|
}
|