Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Settings UseSwagger - minor changes

support47646aa04ccd
diff --git a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
index 8de620076..5fd469c86 100644
--- a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
+++ b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs
@@ -18,11 +18,11 @@ namespace Grand.Api.Infrastructure
{
var backendApiConfig = application.ApplicationServices.GetService<BackendAPIConfig>();
var frontApiConfig = application.ApplicationServices.GetService<FrontendAPIConfig>();
-
- if(backendApiConfig.Enabled)
+ var swagger = application.ApplicationServices.GetService<IConfiguration>().GetValue<bool>("UseSwagger");
+ if (backendApiConfig.Enabled)
application.UseODataQueryRequest();
- if (backendApiConfig.UseSwagger)
+ if (swagger && (backendApiConfig.Enabled || frontApiConfig.Enabled))
{
application.UseSwagger();
application.UseSwaggerUI(c =>
@@ -40,8 +40,8 @@ namespace Grand.Api.Infrastructure
{
var backendApiConfig = services.BuildServiceProvider().GetService<BackendAPIConfig>();
var frontApiConfig = services.BuildServiceProvider().GetService<FrontendAPIConfig>();
-
- if (backendApiConfig.UseSwagger)
+ var swagger = configuration.GetValue<bool>("UseSwagger");
+ if (swagger && (backendApiConfig.Enabled || frontApiConfig.Enabled))
{
services.AddSwaggerGen(c =>
{
diff --git a/src/Core/Grand.Infrastructure/Configuration/BackendAPIConfig.cs b/src/Core/Grand.Infrastructure/Configuration/BackendAPIConfig.cs
index ee241c97e..fc84c2646 100644
--- a/src/Core/Grand.Infrastructure/Configuration/BackendAPIConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/BackendAPIConfig.cs
@@ -3,7 +3,6 @@
public class BackendAPIConfig
{
public bool Enabled { get; set; }
- public bool UseSwagger { get; set; }
public string SecretKey { get; set; }
public bool ValidateIssuer { get; set; }
public string ValidIssuer { get; set; }
diff --git a/src/Web/Grand.Web.Admin/App_Data/appsettings.json b/src/Web/Grand.Web.Admin/App_Data/appsettings.json
index b0a692103..5b610ceb5 100644
--- a/src/Web/Grand.Web.Admin/App_Data/appsettings.json
+++ b/src/Web/Grand.Web.Admin/App_Data/appsettings.json
@@ -63,6 +63,9 @@
//HTTP Strict Transport Security Protocol
"UseHsts": false,
+ //When enabled, allow Razor files to be updated if they're edited.
+ "EnableRuntimeCompilation": true,
+
//We recommend all ASP.NET Core web apps call HTTPS Redirection Middleware to redirect all HTTP requests to HTTPS
"UseHttpsRedirection": false,
"HttpsRedirectionRedirect": 308,
@@ -183,7 +186,6 @@
//api for admin
"BackendAPI": {
"Enabled": false,
- "UseSwagger": false,
"SecretKey": "your private secret key", //at least 16 characters
"ValidateIssuer": false,
"ValidIssuer": "",
@@ -195,12 +197,13 @@
//generate system model
"SystemModel": true
},
-
+ "UseSwagger": false,
//Settings only for advanced users
"Advanced": {
"DbConnectionString": "",
"DbProvider": 0,
- "InstalledPlugins": []
+ //separator comma
+ "InstalledPlugins": ""
},
"Serilog": {
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index b663d5439..1c2ab4bb8 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -248,13 +248,13 @@
//generate system model
"SystemModel": true
},
-
+ "UseSwagger": false,
//Settings only for advanced users
"Advanced": {
"DbConnectionString": "",
"DbProvider": 0,
//separator comma
- "InstalledPlugins": ""
+ "InstalledPlugins": ""
},
"Serilog": {