3 releases (stable)

new 2.0.0 Nov 28, 2023
1.0.0 Oct 7, 2023
0.1.0 Aug 6, 2023

#4 in #rest-api

Download history 306/week @ 2023-08-08 867/week @ 2023-08-15 1005/week @ 2023-08-22 851/week @ 2023-08-29 1086/week @ 2023-09-05 1170/week @ 2023-09-12 1944/week @ 2023-09-19 1282/week @ 2023-09-26 1977/week @ 2023-10-03 1485/week @ 2023-10-10 1958/week @ 2023-10-17 1954/week @ 2023-10-24 2073/week @ 2023-10-31 2122/week @ 2023-11-07 2222/week @ 2023-11-14 2033/week @ 2023-11-21

8,943 downloads per month
Used in 3 crates


4.5K SLoC


Utoipa build crates.io docs.rs rustc

This crate works as a bridge between utoipa and Redoc OpenAPI visualizer.

Utoipa-redoc provides simple mechanism to transform OpenAPI spec resource to a servable HTML file which can be served via predefined framework integration or used standalone and served manually.

You may find fullsize examples from utoipa's Github repository.

Crate Features

  • actix-web Allows serving Redoc via actix-web. version >= 4
  • rocket Allows serving Redoc via rocket. version >=0.5.0-rc.3
  • axum Allows serving Redoc via axum. version >=0.7


Use Redoc only without any boiler plate implementation.

utoipa-redoc = "2"

Enable actix-web integration with Redoc.

utoipa-redoc = { version = "2", features = ["actix-web"] }

Using standalone

Utoipa-redoc can be used standalone as simply as creating a new Redoc instance and then serving it by what ever means available as text/html from http handler in your favourite web framework.

Redoc::to_html method can be used to convert the Redoc instance to a servable html file.

let redoc = Redoc::new(ApiDoc::openapi());

// Then somewhere in your application that handles http operation.
// Make sure you return correct content type `text/html`.
let redoc_handler = move || async {


Utoipa-redoc enables full customizaton support for Redoc according to what can be customized by modifying the HTML template and configuration options.

The default HTML template can be fully overridden to ones liking with Redoc::custom_html method. The HTML template must contain $spec and $config variables which are replaced during Redoc::to_html execution.

  • $spec Will be the Spec that will be rendered via Redoc.
  • $config Will be the current Config. By default this is EmptyConfig.

Overiding the HTML template with a custom one.

let html = "...";


Redoc can be configured with JSON either inlined with the Redoc declaration or loaded from user defined file with FileConfig.

Inlining the configuration.

Redoc::with_config(ApiDoc::openapi(), || json!({ "disableSearch": true }));

Using FileConfig.

Redoc::with_config(ApiDoc::openapi(), FileConfig);

Read more details in Config.


Serve Redoc via actix-web framework.

use actix_web::App;
use utoipa_redoc::{Redoc, Servable};

App::new().service(Redoc::with_url("/redoc", ApiDoc::openapi()));

Serve Redoc via rocket framework.

use utoipa_redoc::{Redoc, Servable};

        Redoc::with_url("/redoc", ApiDoc::openapi()),

Serve Redoc via axum framework.

use axum::Router;
use utoipa_redoc::{Redoc, Servable};

let app = Router::<S>::new()
    .merge(Redoc::with_url("/redoc", ApiDoc::openapi()));

Use Redoc to serve OpenAPI spec from url.


Use Redoc to serve custom OpenAPI spec using serde's json!() macro.

Redoc::new(json!({"openapi": "3.1.0"}));


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.


~612K SLoC