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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! JSON Schema generation from Rust message types.
//!
//! This module provides functionality to generate JSON Schema from Rust structs
//! marked with `#[derive(Serialize, Deserialize)]` or `#[derive(Message)]`.
//!
//! # Use Cases
//!
//! - API documentation and contract definition
//! - Validation schemas for JSON payloads
//! - OpenAPI/Swagger integration
//! - Self-documenting plugin bundles
//!
//! # Usage
//!
//! ## Command Line
//!
//! ```bash
//! rustbridge generate json-schema -i src/messages.rs -o schema.json
//! ```
//!
//! ## Programmatic
//!
//! ```rust,no_run
//! use rustbridge_cli::codegen::{MessageType, generate_json_schema};
//! use std::path::Path;
//!
//! // Parse Rust source
//! let messages = MessageType::parse_file(Path::new("src/messages.rs")).unwrap();
//!
//! // Generate JSON Schema
//! let schema = generate_json_schema(&messages).unwrap();
//! println!("{}", serde_json::to_string_pretty(&schema).unwrap());
//! ```
//!
//! # Supported Types
//!
//! - **Primitives**: `String`, `bool`, `i8..i64`, `u8..u64`, `f32`, `f64`
//! - **Containers**: `Vec<T>`, `Option<T>`
//! - **Custom types**: Other `#[derive(Serialize, Deserialize)]` structs
//!
//! # Examples
//!
//! ```rust
//! use serde::{Serialize, Deserialize};
//!
//! /// A user profile.
//! #[derive(Serialize, Deserialize)]
//! pub struct UserProfile {
//! /// User ID.
//! pub id: u64,
//!
//! /// Display name.
//! #[serde(rename = "displayName")]
//! pub display_name: String,
//!
//! /// Email address (optional).
//! pub email: Option<String>,
//!
//! /// User tags.
//! pub tags: Vec<String>,
//! }
//! ```
//!
//! The generated JSON Schema will include proper types, documentation from doc comments,
//! and required field annotations.
pub use MessageType;
pub use generate_json_schema;