use anyhow::Result;
use serde_json::Value;
pub mod base;
pub mod elixir;
pub mod php;
pub mod python;
pub mod ruby;
pub mod rust;
pub mod typescript;
pub use elixir::ElixirAsyncApiGenerator;
pub use php::PhpAsyncApiGenerator;
pub use python::PythonAsyncApiGenerator;
pub use ruby::RubyAsyncApiGenerator;
pub use rust::RustAsyncApiGenerator;
pub use typescript::TypeScriptAsyncApiGenerator;
pub trait AsyncApiGenerator {
fn generate_test_app(&self, channels: &[ChannelInfo], protocol: &str) -> Result<String>;
fn generate_handler_app(&self, channels: &[ChannelInfo], protocol: &str) -> Result<String>;
}
#[derive(Debug, Clone)]
pub struct ChannelMessage {
pub name: String,
pub schema_name: String,
pub schema: Option<Value>,
}
#[derive(Debug, Clone)]
pub struct ChannelInfo {
pub name: String,
pub path: String,
pub messages: Vec<String>,
pub message_definitions: Vec<ChannelMessage>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_channel_info_structure() {
let channel = ChannelInfo {
name: "updates".to_string(),
path: "/updates".to_string(),
messages: vec!["UserUpdated".to_string()],
message_definitions: vec![ChannelMessage {
name: "UserUpdated".to_string(),
schema_name: "UserUpdated".to_string(),
schema: Some(serde_json::json!({"type": "object"})),
}],
};
assert_eq!(channel.path, "/updates");
assert_eq!(channel.messages.len(), 1);
assert_eq!(channel.message_definitions.len(), 1);
}
}