Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Installation

The crate

A server that defines and serves an API with axum needs:

cargo add reflectapi --features builder,axum

Add features for the third-party types your API uses, for example --features builder,axum,chrono,uuid. Without its feature, a type such as chrono::DateTime can't be part of an Input or Output type.

FeatureEnables
builderBuilder and the routers: defining an API
axumreflectapi::axum: serving the routes with axum (implies builder)
msgpackMessagePack request and response bodies beside JSON (implies builder)
codegenreflectapi::codegen: generating clients or OpenAPI from Rust code instead of the CLI
glob (default)Builder::glob_rename_types
chrono, chrono-tzchrono dates and times, chrono_tz::Tz
uuiduuid::Uuid
urlurl::Url
rust_decimalrust_decimal::Decimal
indexmapIndexMap and IndexSet
jsonserde_json::Value as an untyped value
rtThe runtime of generated Rust clients
reqwest, reqwest-middlewareA generated Rust client calling over reqwest, or reqwest-middleware
rt-sseStreaming routes in generated Rust clients

A crate holding a generated Rust client depends on reflectapi with rt, plus reqwest to make the calls and rt-sse if the API streams. See Generated clients.

The CLI

The reflectapi CLI generates clients from a schema file:

cargo binstall reflectapi-cli   # a prebuilt binary
cargo install reflectapi-cli    # or build it

Use the CLI release that matches the reflectapi crate that wrote the schema.

The Python runtime

Generated Python clients import the reflectapi-runtime package; see Generate a Python Client.