25 releases (stable)

6.0.0 Jan 9, 2024
5.0.0 Nov 28, 2023
4.0.0 Oct 7, 2023
3.1.6 Oct 7, 2023
0.1.0-beta1 Mar 7, 2022

#66 in Web programming

Download history 29533/week @ 2023-11-07 45121/week @ 2023-11-14 24657/week @ 2023-11-21 27087/week @ 2023-11-28 21789/week @ 2023-12-05 23765/week @ 2023-12-12 17486/week @ 2023-12-19 11594/week @ 2023-12-26 24408/week @ 2024-01-02 27480/week @ 2024-01-09 30591/week @ 2024-01-16 28342/week @ 2024-01-23 28686/week @ 2024-01-30 28902/week @ 2024-02-06 31149/week @ 2024-02-13 22960/week @ 2024-02-20

117,180 downloads per month
Used in 32 crates (30 directly)


5.5K SLoC


Utoipa build crates.io docs.rs rustc

This crate implements necessary boilerplate code to serve Swagger UI via web server. It works as a bridge for serving the OpenAPI documentation created with utoipa library in the Swagger UI.

Currently implemented boilerplate for:

  • actix-web version >= 4
  • rocket version >=0.5
  • axum version >=0.7

Serving Swagger UI is framework independent thus this crate also supports serving the Swagger UI with other frameworks as well. With other frameworks, there is a bit more manual implementation to be done. See more details at serve or examples.

Crate Features

  • actix-web Enables actix-web integration with pre-configured SwaggerUI service factory allowing users to use the Swagger UI without a hassle.
  • rocket Enables rocket integration with pre-configured routes for serving the Swagger UI and api doc without a hassle.
  • axum Enables axum integration with pre-configured Router serving Swagger UI and OpenAPI specs hazzle free.
  • debug-embed Enables debug-embed feature on rust_embed crate to allow embedding files in debug builds as well.


Use only the raw types without any boilerplate implementation.

utoipa-swagger-ui = "6"

Enable actix-web framework with Swagger UI you could define the dependency as follows.

utoipa-swagger-ui = { version = "6", features = ["actix-web"] }

Note! Also remember that you already have defined utoipa dependency in your Cargo.toml


Serve Swagger UI with api doc via actix-web. See full example from examples.

HttpServer::new(move || {
                .url("/api-docs/openapi.json", ApiDoc::openapi()),
  .bind((Ipv4Addr::UNSPECIFIED, 8989)).unwrap()

Serve Swagger UI with api doc via rocket. See full example from examples.

fn rocket() -> Rocket<Build> {
                .url("/api-docs/openapi.json", ApiDoc::openapi()),

Setup Router to serve Swagger UI with axum framework. See full implementation of how to serve Swagger UI with axum from examples.

let app = Router::new()
        .url("/api-docs/openapi.json", ApiDoc::openapi()));


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.


~639K SLoC