9 releases

0.2.0 Jan 16, 2025
0.1.4 Jan 5, 2025
0.1.3 Dec 19, 2024
0.1.2 Oct 29, 2024
0.1.0-beta.2 Sep 4, 2024

#916 in HTTP server

Download history 2715/week @ 2024-12-24 2852/week @ 2024-12-31 6159/week @ 2025-01-07 6311/week @ 2025-01-14 6630/week @ 2025-01-21 7216/week @ 2025-01-28 9481/week @ 2025-02-04 10651/week @ 2025-02-11 16080/week @ 2025-02-18 47217/week @ 2025-02-25 51062/week @ 2025-03-04 52561/week @ 2025-03-11 46278/week @ 2025-03-18 37041/week @ 2025-03-25 52411/week @ 2025-04-01 44562/week @ 2025-04-08

186,516 downloads per month
Used in 13 crates (9 directly)

MIT/Apache

410KB
6K SLoC

utoipa-axum - Bindings for Axum and utoipa

Utoipa build crates.io docs.rs rustc

Utoipa axum brings utoipa and axum closer together by the way of providing an ergonomic API that is extending on the axum API. It gives a natural way to register handlers known to axum and also simultaneously generates OpenAPI specification from the handlers.

Crate features

  • debug: Implement debug traits for types.

Install

Add dependency declaration to Cargo.toml.

[dependencies]
utoipa-axum = "0.2"

Examples

Use OpenApiRouter to collect handlers with #[utoipa::path] macro to compose service and form OpenAPI spec.

use utoipa_axum::{routes, PathItemExt, router::OpenApiRouter};

#[derive(utoipa::ToSchema)]
struct User {
    id: i32,
}

#[utoipa::path(get, path = "/user", responses((status = OK, body = User)))]
async fn get_user() -> Json<User> {
    Json(User { id: 1 })
}

let (router, api) = OpenApiRouter::new()
    .routes(routes!(get_user))
    .split_for_parts();

License

Licensed under either of Apache 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, shall be dual licensed, without any additional terms or conditions.

Dependencies

~3.5–5MB
~98K SLoC