目标生成器
这一页汇总当前 xidlc 内建支持的目标,以及它们通常用于什么场景。
| 目标 | 常见别名 | 产物类型 | 典型搭配 |
|---|---|---|---|
rust | rs | Rust 类型和模块 | Rust 库或应用 |
rust-jsonrpc | rust_jsonrpc, rs_jsonrpc, rs-jsonrpc | Rust JSON-RPC 绑定 | xidl-jsonrpc |
rust-axum | rust_axum, axum, rs_axum, rs-axum | Rust HTTP / Stream 绑定 | xidl-rust-axum |
typescript | ts | TypeScript 声明和 Schema | 前端或工具链 |
go | golang | Go 类型或辅助代码 | Go 项目 |
go-rest | go_rest | Go HTTP 绑定 | Go HTTP 服务 |
python | py | Python 代码生成 | Python 项目 |
python-rest | py_rest, python_rest | Python HTTP 绑定 | Python HTTP 服务 |
openapi | 无 | openapi_{filename}.json | 文档和下游消费 |
openrpc | open-rpc | openrpc.json | JSON-RPC 文档 |
--client 和 --server
Section titled “--client 和 --server”有些生成器支持区分客户端和服务端产物,例如:
rust-axumrust-jsonrpc
如果某个目标不支持这种区分,这两个参数可能会被忽略,或者效果不明显。
什么时候选哪个目标
Section titled “什么时候选哪个目标”- 你只要数据结构:选
rust、typescript、go、python - 你要 HTTP 服务能力:选
rust-axum、go-rest、python-rest - 你要 JSON-RPC:选
rust-jsonrpc - 你要对外发布 HTTP 契约:选
openapi - 你要对外发布 JSON-RPC 契约:选
openrpc - 你在调试内部表示:选
hir、rest-hir、typed-ast
Schema 文件输出
Section titled “Schema 文件输出”除了生成代码外, XIDL 还可以生成适用于 HTTP 和 JSON-RPC 的 OpenAPI 和 OpenRPC 文件文件:
openapiopenrpc