1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//! Binary to generate Rust structs from a JSON Schema. //! //! Usage: `json-schema-gen < input.json > output.rs` //! //! Reads a JSON Schema from stdin and writes generated Rust structs to stdout. use std::io::{read_to_string, stdin, stdout}; use std::process; use json_schema_rs::generate_to_writer; fn main() { let schema_json: String = match read_to_string(stdin()) { Ok(s) => s, Err(e) => { eprintln!("Error reading stdin: {e}"); process::exit(1); } }; if let Err(e) = generate_to_writer(&schema_json, &mut stdout()) { eprintln!("Error: {e}"); process::exit(1); } }