Skip to content

Commit

Permalink
Update default Swagger UI version (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaku committed May 5, 2024
1 parent 9713b26 commit 926a5e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion utoipa-swagger-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The following configuration env variables are available at build time:
* `SWAGGER_UI_DOWNLOAD_URL`:

* the url from where to download the swagger-ui zip file
* default value: <https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.11.0.zip>
* default value: <https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip>
* All versions: <https://github.com/swagger-api/swagger-ui/tags>

* `SWAGGER_UI_OVERWRITE_FOLDER`:
Expand Down
8 changes: 4 additions & 4 deletions utoipa-swagger-ui/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zip_next::{result::ZipError, ZipArchive};
/// + absolute path to a folder containing files to overwrite the default swagger-ui files

const SWAGGER_UI_DOWNLOAD_URL_DEFAULT: &str =
"https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.11.0.zip";
"https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip";

fn main() {
let target_dir = env::var("OUT_DIR").unwrap();
Expand All @@ -28,7 +28,7 @@ fn main() {
env::var("SWAGGER_UI_DOWNLOAD_URL").unwrap_or(SWAGGER_UI_DOWNLOAD_URL_DEFAULT.to_string());

println!("SWAGGER_UI_DOWNLOAD_URL: {}", url);
let zip_filename = url.split("/").last().unwrap().to_string();
let zip_filename = url.split('/').last().unwrap().to_string();
let zip_path = [&target_dir, &zip_filename].iter().collect::<PathBuf>();

if !zip_path.exists() {
Expand Down Expand Up @@ -156,7 +156,7 @@ struct SwaggerUiDist;
target_dir, zip_top_level_folder
);
let path = [target_dir, "embed.rs"].iter().collect::<PathBuf>();
fs::write(&path, &contents).unwrap();
fs::write(path, contents).unwrap();
}

fn download_file(url: &str, path: PathBuf) -> Result<(), Box<dyn Error>> {
Expand All @@ -178,7 +178,7 @@ fn overwrite_target_file(target_dir: &str, swagger_ui_dist_zip: &str, path_in: P
.iter()
.collect::<PathBuf>();

fs::write(&path, &content).unwrap();
fs::write(path, content).unwrap();
}
Err(_) => {
println!("cannot read content from file: {:?}", path_in);
Expand Down
21 changes: 18 additions & 3 deletions utoipa-swagger-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! * **actix-web** `version >= 4`
//! * **rocket** `version >=0.5`
//! * **axum** `version >=0.6`
//! * **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 bit more manual implementation to be done. See
Expand All @@ -33,17 +33,32 @@
//! Use only the raw types without any boiler plate implementation.
//! ```toml
//! [dependencies]
//! utoipa-swagger-ui = "3"
//! utoipa-swagger-ui = "6"
//! ```
//!
//! Enable actix-web framework with Swagger UI you could define the dependency as follows.
//! ```toml
//! [dependencies]
//! utoipa-swagger-ui = { version = "3", features = ["actix-web"] }
//! utoipa-swagger-ui = { version = "6", features = ["actix-web"] }
//! ```
//!
//! **Note!** Also remember that you already have defined `utoipa` dependency in your `Cargo.toml`
//!
//! ## Config
//!
//! The following configuration env variables are available at build time:
//!
//! * `SWAGGER_UI_DOWNLOAD_URL`:
//!
//! * the url from where to download the swagger-ui zip file
//! * default value: <https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip>
//! * All versions: <https://github.com/swagger-api/swagger-ui/tags>
//!
//! * `SWAGGER_UI_OVERWRITE_FOLDER`:
//!
//! * absolute path to a folder containing files to overwrite the default swagger-ui files
//! * typically you might want to overwrite `index.html`
//!
//! # Examples
//!
//! Serve Swagger UI with api doc via **`actix-web`**. See full example from
Expand Down

0 comments on commit 926a5e8

Please sign in to comment.