Skip to main content

mount_docs

Function mount_docs 

Source
pub fn mount_docs<S>(
    router: Router<S>,
    api_doc: ApiDoc,
    opts: MountOpts,
) -> Router<S>
where S: Clone + Send + Sync + 'static,
Expand description

Mount the OpenAPI JSON endpoint (and a documentation UI, if a UI feature is enabled) on the supplied router.

The JSON handler closes over the ApiDoc’s pre-serialized Bytes and clones it on each request — zero allocations beyond the reference count bump.

§Example

use axum::Router;
use doxa::{mount_docs, ApiDocBuilder, MountOpts};

let api_doc = ApiDocBuilder::new().title("test").version("0.1").build();
let app: Router = mount_docs(Router::new(), api_doc, MountOpts::default());