#axum #utoipa #bindings

utoipa-axum

Utoipa's axum bindings for seamless integration for the two

7 releases

0.1.2 Oct 29, 2024
0.1.1 Oct 16, 2024
0.1.0-beta.2 Sep 4, 2024

#1553 in Web programming

Download history 248/week @ 2024-08-28 195/week @ 2024-09-04 120/week @ 2024-09-11 161/week @ 2024-09-18 171/week @ 2024-09-25 269/week @ 2024-10-02 315/week @ 2024-10-09 1088/week @ 2024-10-16 1792/week @ 2024-10-23 1539/week @ 2024-10-30 1548/week @ 2024-11-06 1993/week @ 2024-11-13

7,087 downloads per month
Used in docker_compose_spec

MIT/Apache

415KB
6.5K 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.1"

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