dioxus-openapi
OpenAPI (utoipa) for Dioxus 0.7 server functions, without retyping paths.
What it does
| Piece | Role |
|---|---|
#[api_get] / #[api_post] |
Expand to Dioxus #[get]/#[post] and a utoipa path stub |
| Inventory registration | Paths/schemas collected automatically (no manual paths(...) list) |
build_openapi |
Assemble OpenAPI 3.x from registered paths |
scalar_html |
Standalone Scalar UI shell (Agent/MCP/client off by default) |
POST bodies that are not path params become a generated ToSchema struct matching Dioxus’s named JSON object packing. Operation tags are applied correctly for Scalar’s sidebar.
Install
[]
= "0.1"
= { = "5", = true } # if you derive ToSchema on models
[]
= [
"dioxus/server",
"dioxus-openapi/server",
"dep:utoipa",
]
Usage
use ;
pub async
const SPEC: SpecOptions = SpecOptions ;
// Mount as plain axum routes (do not Router::merge a different state into Dioxus):
// .route("/api/openapi.json", get(|| async { Json(build_openapi(&SPEC)) }))
// .route("/api/docs", get(|| async { Html(scalar_html(&ScalarOptions { … })) }))
Wire types used in responses should derive utoipa::ToSchema on the server: