Why axum-autodoc
axum-autodoc brings the developer experience of @elysiajs/openapi to axum: you write ordinary handlers and the documentation is inferred from what they already say.
The signature is the source of truth
An axum handler signature already tells you almost everything a client needs to know:
- which path, query and header parameters it reads,
- what body it accepts and in which media type,
- whether it needs a token,
- what it returns on success and which errors it can produce.
Most OpenAPI libraries ask you to say all of that a second time in an annotation. Two copies drift. axum-autodoc reads the first copy instead, so there is nothing to keep in sync.
It does not compile if it cannot be documented
If a handler uses an extractor or return type that cannot be documented, the route does not compile. The docs cannot silently fall behind the code.
Compared
| axum-autodoc | utoipa | aide | |
|---|---|---|---|
| No per-handler annotation | yes | no | yes |
| Validation from the same schema | yes | no | no |
| Every status that can happen | yes | no | no |
| Typed TypeScript client | yes | no | no |
What you get
| Route | Serves |
|---|---|
/openapi | Scalar API reference (or Swagger UI) |
/openapi/json | OpenAPI 3.2 document |
/client.ts | Typed TypeScript client (feature ts) |
The paths, the Scalar default and the builder options follow @elysiajs/openapi, so if you have used Elysia the configuration will feel familiar.
Status
axum-autodoc is at 0.2. The API may still change before 1.0. The minimum supported Rust version is 1.88.
Ready? Head to the quick start.