Generate HTTP/JSONRPC/OpenAPI/OpenRPC with a code generator!

⚓ Rust    📅 2026-03-09    👤 surdeus    👁️ 2      

surdeus

Hello everyone. I'd like to recommend to you a IDL code generator.

It can generate HTTP servers via IDL and generate OpenAPI documentation.

It also supports generating JSONRPC servers and generating OpenRPC documents.

JSONRPC can be served on inproc://xxx or tcp/tls/ws/wss breakpoints.

In simple terms, you write an IDL file and then I generate some scaffolding. Then you implement specific traits for the type, and finally I generate routes from the type.

such as:

    use xidlc_examples::hello_world::HelloWorld;
    use xidlc_examples::hello_world::HelloWorldSayHelloRequest;
    use xidlc_examples::hello_world::HelloWorldServer;
    
    
    struct HelloWorldImpl;
    
    
    #[async_trait::async_trait]
    impl HelloWorld for HelloWorldImpl {
        async fn sayHello(
            &self,
            req: xidl_rust_axum::Request<HelloWorldSayHelloRequest>,
        ) -> Result<(), xidl_rust_axum::Error> {
            let HelloWorldSayHelloRequest { name } = req.data;
            println!("Hello, {}!", name);
            Ok(())
        }
    }
    
    
    #[tokio::main]
    async fn main() -> Result<(), Box<dyn std::error::Error>> {
        let addr = "127.0.0.1:3000";
        println!("axum hello_world server listening on {addr}");
    
    
        xidl_rust_axum::Server::builder()
            .with_service(HelloWorldServer::new(HelloWorldImpl))
            .serve(addr)
            .await?;
    
    
        Ok(())
    }

You can use my framework directly to listen to the service, or you can pass routes to axum to use other middleware. It's all up to you! ! !

Play it now with playground.

Or install with:

cargo install xidlc

You can find more example here.

If you find this useful to you, please star me :slight_smile:

1 post - 1 participant

Read full topic

🏷️ Rust_feed