Autogenerate only the models of the API for the backend-server
This commit is contained in:
24
backend-actix/build.rs
Normal file
24
backend-actix/build.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user