#[openrpc]Expand description
Generate OpenRPC specification for JSON-RPC services.
OpenRPC is to JSON-RPC what OpenAPI is to REST APIs.
§Example
ⓘ
use server_less::openrpc;
struct Calculator;
#[openrpc(title = "Calculator API", version = "1.0.0")]
impl Calculator {
/// Add two numbers
fn add(&self, a: i32, b: i32) -> i32 { a + b }
}
// Get OpenRPC spec as JSON
let spec = Calculator::openrpc_spec();
let json = Calculator::openrpc_json();
// Write to file
Calculator::write_openrpc("openrpc.json")?;