From 7509ab4c7339792f327296441da623a2c1d7677f Mon Sep 17 00:00:00 2001 From: Mag Artur Date: Fri, 17 May 2024 15:25:25 +0700 Subject: [PATCH 1/8] Move css and js to parameters, for available to use cdn. --- .../SwaggerUIMiddleware.cs | 3 +++ .../SwaggerUIOptions.cs | 15 +++++++++++++++ src/Swashbuckle.AspNetCore.SwaggerUI/index.html | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs index 52dac4b73e..bbfdf747ee 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIMiddleware.cs @@ -163,6 +163,9 @@ private Dictionary GetIndexArguments() { { "%(DocumentTitle)", _options.DocumentTitle }, { "%(HeadContent)", _options.HeadContent }, + { "%(PathCss)", _options.PathCss }, + { "%(PathBundleJs)", _options.PathBundleJs }, + { "%(PathStandaloneJs)", _options.PathStandaloneJs }, { "%(ConfigObject)", configObject }, { "%(OAuthConfigObject)", oauthConfigObject }, { "%(Interceptors)", interceptors }, diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs index cd9aa9df42..d8b7f34553 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptions.cs @@ -50,6 +50,21 @@ public class SwaggerUIOptions /// Gets or sets the optional JSON serialization options to use to serialize options to the HTML document. /// public JsonSerializerOptions JsonSerializerOptions { get; set; } + + /// + /// Path to bundle js file. + /// + public string PathBundleJs { get; set; } = "./swagger-ui-bundle.js"; + + /// + /// Path to standalone js file. + /// + public string PathStandaloneJs { get; set; } = "./swagger-ui-standalone-preset.js"; + + /// + /// Path to css file. + /// + public string PathCss { get; set; } = "./swagger-ui.css"; } public class ConfigObject diff --git a/src/Swashbuckle.AspNetCore.SwaggerUI/index.html b/src/Swashbuckle.AspNetCore.SwaggerUI/index.html index c5360b2859..20526f8453 100644 --- a/src/Swashbuckle.AspNetCore.SwaggerUI/index.html +++ b/src/Swashbuckle.AspNetCore.SwaggerUI/index.html @@ -4,7 +4,7 @@ %(DocumentTitle) - +