From 39ef61f56e6304250a42c40752b407c639dcb9d3 Mon Sep 17 00:00:00 2001 From: Juha Kukkonen Date: Wed, 22 Mar 2023 01:50:59 +0200 Subject: [PATCH] Swagger UI debug embed (#534) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add explanation of Swagger UI not being embedded on debug builds --------- Co-authored-by: DaniƩl Kerkmann --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2301e975..d1e25bbd 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,19 @@ This would produce api doc something similar to: - More about OpenAPI security in [security documentation](https://docs.rs/utoipa/latest/utoipa/openapi/security/index.html). - Dump generated API doc to file at build time. See [issue 214 comment](https://github.com/juhaku/utoipa/issues/214#issuecomment-1179589373). +## General Pitfalls + +#### Swagger UI returns 404 Not Found from build binary + +This is highly probably due to `RustEmbed` not embedding the Swagger UI to the executable. This is natural since the `RustEmbed` +library **does not** by default embed files on debug builds. To fix this you can do one of the following. + +1. Build your executable in `--release` mode +2. or add `debug-embed` feature flag to your `Cargo.toml` for `utoipa-swagger-ui`. This will enable the debug emebed feature flag for + `RustEmbed` as well. Read more about this [here](https://github.com/juhaku/utoipa/issues/527#issuecomment-1474219098) and [here](https://github.com/juhaku/utoipa/issues/268). + +Find `utoipa-swagger-ui` [feature flags here](https://github.com/juhaku/utoipa/tree/master/utoipa-swagger-ui#crate-features). + # License Licensed under either of [Apache 2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) license at your option.