Skip to content

Commit 926a5e8

Browse files
authored
Update default Swagger UI version (#905)
1 parent 9713b26 commit 926a5e8

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

utoipa-swagger-ui/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The following configuration env variables are available at build time:
5656
* `SWAGGER_UI_DOWNLOAD_URL`:
5757

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

6262
* `SWAGGER_UI_OVERWRITE_FOLDER`:

utoipa-swagger-ui/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use zip_next::{result::ZipError, ZipArchive};
1818
/// + absolute path to a folder containing files to overwrite the default swagger-ui files
1919
2020
const SWAGGER_UI_DOWNLOAD_URL_DEFAULT: &str =
21-
"https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.11.0.zip";
21+
"https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip";
2222

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

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

3434
if !zip_path.exists() {
@@ -156,7 +156,7 @@ struct SwaggerUiDist;
156156
target_dir, zip_top_level_folder
157157
);
158158
let path = [target_dir, "embed.rs"].iter().collect::<PathBuf>();
159-
fs::write(&path, &contents).unwrap();
159+
fs::write(path, contents).unwrap();
160160
}
161161

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

181-
fs::write(&path, &content).unwrap();
181+
fs::write(path, content).unwrap();
182182
}
183183
Err(_) => {
184184
println!("cannot read content from file: {:?}", path_in);

utoipa-swagger-ui/src/lib.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! * **actix-web** `version >= 4`
1111
//! * **rocket** `version >=0.5`
12-
//! * **axum** `version >=0.6`
12+
//! * **axum** `version >=0.7`
1313
//!
1414
//! Serving Swagger UI is framework independent thus this crate also supports serving the Swagger UI with
1515
//! other frameworks as well. With other frameworks there is bit more manual implementation to be done. See
@@ -33,17 +33,32 @@
3333
//! Use only the raw types without any boiler plate implementation.
3434
//! ```toml
3535
//! [dependencies]
36-
//! utoipa-swagger-ui = "3"
36+
//! utoipa-swagger-ui = "6"
3737
//! ```
3838
//!
3939
//! Enable actix-web framework with Swagger UI you could define the dependency as follows.
4040
//! ```toml
4141
//! [dependencies]
42-
//! utoipa-swagger-ui = { version = "3", features = ["actix-web"] }
42+
//! utoipa-swagger-ui = { version = "6", features = ["actix-web"] }
4343
//! ```
4444
//!
4545
//! **Note!** Also remember that you already have defined `utoipa` dependency in your `Cargo.toml`
4646
//!
47+
//! ## Config
48+
//!
49+
//! The following configuration env variables are available at build time:
50+
//!
51+
//! * `SWAGGER_UI_DOWNLOAD_URL`:
52+
//!
53+
//! * the url from where to download the swagger-ui zip file
54+
//! * default value: <https://github.com/swagger-api/swagger-ui/archive/refs/tags/v5.17.3.zip>
55+
//! * All versions: <https://github.com/swagger-api/swagger-ui/tags>
56+
//!
57+
//! * `SWAGGER_UI_OVERWRITE_FOLDER`:
58+
//!
59+
//! * absolute path to a folder containing files to overwrite the default swagger-ui files
60+
//! * typically you might want to overwrite `index.html`
61+
//!
4762
//! # Examples
4863
//!
4964
//! Serve Swagger UI with api doc via **`actix-web`**. See full example from

0 commit comments

Comments
 (0)