Skip to content
Clone
fb04cec
21 lines 631 B Rust
use std::path::PathBuf;
use anyhow::{Context, anyhow};
use webapi::openapi::api_doc;
fn main() -> anyhow::Result<()> {
let json = api_doc()
.to_pretty_json()
.context("serializing openapi doc")?;
let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let root = crate_dir
.ancestors()
.nth(2)
.ok_or_else(|| anyhow!("workspace root not found above {}", crate_dir.display()))?;
let output = root.join("openapi.json");
std::fs::write(&output, json).with_context(|| format!("writing {}", output.display()))?;
println!("wrote {}", output.display());
Ok(())
}