use asyncapi_rust::{AsyncApi, AsyncApiSpec};
use std::fs;
use std::path::Path;
#[derive(AsyncApi)]
#[asyncapi(
title = "Example WebSocket API",
version = "1.0.0",
description = "A real-time API for demonstration purposes"
)]
struct ExampleApi;
fn main() {
println!("🚀 Generating AsyncAPI specification file...\n");
let spec: AsyncApiSpec = ExampleApi::asyncapi_spec();
let json = serde_json::to_string_pretty(&spec).expect("Failed to serialize AsyncAPI spec");
let output_dir = Path::new("target/asyncapi");
fs::create_dir_all(output_dir).expect("Failed to create output directory");
let output_path = output_dir.join("asyncapi.json");
fs::write(&output_path, &json).expect("Failed to write spec file");
println!("✅ Generated: {}", output_path.display());
println!("\n📄 Specification preview:");
println!("{}", json);
println!("\n💡 Usage Tips:");
println!(" • Commit this file to git for version tracking");
println!(" • Use in CI/CD: cargo run --bin generate-asyncapi");
println!(" • Include in rustdoc: #[doc = include_str!(\"path/to/asyncapi.json\")]");
println!(" • Validate with AsyncAPI tools: asyncapi validate asyncapi.json");
}