honig: OpenAPI 3.2 to a Rust client and server.
It is meant for spec-first workflow and catches drift from the OpenAPI description at compile time.
It supports OpenAPI 3.2 and earlier, focusing on both correctness and runtime performance.
honig installs as a pre-built binary with cargo-binstall:
cargo binstall cargo-honigThese commands add honig to your crate:
cargo honig init path/to/openapi.yaml
cargo add honig@=x.y.z -F client,server,...
cargo honig generateinit adds the [package.metadata.honig.api] section to your Cargo.toml and prints the exact cargo add lines:
honig with every feature that the description needs, such as regress for a pattern.
generate writes the module to src/api. It never edits Cargo.toml.
When the code needs a honig feature that is off, generate stops and prints the cargo add line that turns it on.
Then you can declare the module in src/lib.rs or src/main.rs:
pub mod api;The book's recipes build whole setups: a server and its client, a web app next to its API, auth from a layer that you already run, and a full middleware stack.
cargo honig generate updates the module after every change to the description.
Every place your code must change becomes a compile error: a new operation is a missing method, a new response is a missing match arm.
Run cargo honig generate --check in CI to assert that the module is up to date with the description or the generator.
Install the new generator, then generate again:
cargo binstall cargo-honig
cargo honig generategenerate moves the honig dependency to the version of the generator. The two always match: the generated code calls runtime internals that change between versions.
The book covers usage and features.