| Crates.io | utoipa-axum |
| lib.rs | utoipa-axum |
| version | 0.2.0 |
| created_at | 2024-09-01 19:09:54.982925+00 |
| updated_at | 2025-01-16 09:39:14.367859+00 |
| description | Utoipa's axum bindings for seamless integration for the two |
| homepage | |
| repository | https://github.com/juhaku/utoipa |
| max_upload_size | |
| id | 1359827 |
| size | 52,338 |
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.
debug: Implement debug traits for types.Add dependency declaration to Cargo.toml.
[dependencies]
utoipa-axum = "0.2"
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();
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.