24 lines
774 B
Rust

use std::{fs::{self, File}, io::Write, process::Command};
fn main() {
let _ =
Command::new("openapi-generator")
.args(["generate", "-i", "gamenight-api.yaml", "-g", "rust", "--global-property", "models"])
.output()
.expect("Failed to generate models sources for the gamenight API");
let mut file = File::create("src/models/mod.rs").unwrap();
let paths = fs::read_dir("./src/models").unwrap();
for path in paths {
let path = path.unwrap();
let path = path.path();
let stem = path.file_stem().unwrap();
if stem == "mod" {
continue
}
let line = format!("pub mod {};\n", stem.to_str().unwrap());
file.write(line.as_bytes()).unwrap();
}
}