Expand description
OpenAPI for Dioxus server functions.
Pair api_get / api_post with build_openapi so paths never need
to be listed twice: the macros expand to Dioxus #[get]/#[post] and
inventory-register a utoipa path (with tags applied correctly for Scalar).
§App setup
[dependencies]
dioxus-openapi = "0.1"
[features]
server = ["dioxus/server", "dioxus-openapi/server"]ⓘ
use dioxus_openapi::{api_get, api_post, build_openapi, SpecOptions, TagMeta};
#[api_get("/api/hello", tag = "demo")]
pub async fn hello() -> Result<String> { Ok("hi".into()) }
const SPEC: SpecOptions = SpecOptions {
title: "My API",
version: "0.1.0",
description: Some("…"),
tags: &[TagMeta { name: "demo", description: Some("Demo routes") }],
};
// GET /api/openapi.json
async fn openapi_json() -> axum::Json<utoipa::openapi::OpenApi> {
axum::Json(build_openapi(&SPEC))
}Structs§
- Registered
Path server - One documented endpoint, registered by
crate::api_get/crate::api_post. - Scalar
Options server - Options for the Scalar interactive API reference HTML shell.
- Spec
Options server - Document-level OpenAPI info + optional tag descriptions.
- TagMeta
server - Tag metadata for the top-level OpenAPI
tagsarray (sidebar descriptions).
Functions§
- append_
tagged_ path server - Like
PathsBuilder::path_from, but also copies tags from [utoipa::__dev::Tags] onto the operation. - build_
openapi server - Build the full OpenAPI document from all inventory-registered paths.
- scalar_
html server - Build a standalone Scalar HTML document for
GET /api/docs(or similar).