diff --git a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
index 1076e8c..3456050 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
@@ -4,7 +4,7 @@
net6.0;net7.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet
diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
index 01080ca..b4d5796 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
@@ -4,7 +4,7 @@
net6.0;net7.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet,aspcore,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
index 6d79594..8cd5753 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
+++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
@@ -20,6 +20,7 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
+using Swashbuckle.AspNetCore.SwaggerUI;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -140,6 +141,21 @@ public static IServiceCollection UseActivityChangeLog(this IServiceCollection se
return services;
}
+
+ static void UseSwaggerUI(IConfiguration config,Func,IApplicationBuilder> swagger)
+ {
+ var ui = config.GetSection("Swagger:SwaggerUI").Get();
+ swagger(so =>
+ {
+ if (ui.Endpoints?.Length > 0)
+ {
+ foreach (var item in ui.Endpoints)
+ {
+ so.SwaggerEndpoint(item.Url, item.Name);
+ }
+ }
+ });
+ }
///
///
///
@@ -149,16 +165,22 @@ public static IServiceCollection UseActivityChangeLog(this IServiceCollection se
public static async Task Build(this IApplicationBuilder app)
where TContext : RelationalCoreContext
{
+ IConfiguration config = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .Build();
app.UseDeveloperExceptionPage();
- // Configure the HTTP request pipeline.
- app.UseSwagger();
- app.UseSwaggerUI();
+
+ var useSwagger = config["Authorization:IsUse"];
+ var doUseSwagger = useSwagger.HasValue() && useSwagger.Equals("true", StringComparison.OrdinalIgnoreCase);
+ if (doUseSwagger)
+ {
+ app.UseSwagger();
+ UseSwaggerUI(config, app.UseSwaggerUI);
+ }
+
app.UseHttpsRedirection();
app.UseAuthorization();
- IConfiguration config = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .Build();
//app.MapControllers();
//app.Run(build);
using (var scope = app.ApplicationServices.CreateAsyncScope())
@@ -191,7 +213,7 @@ public static WebApplication Build(this WebApplicationBuilder app)
static bool PreBuild(WebApplicationBuilder app)
{
- var useAuth = app.Configuration["Authorization:Use"];
+ var useAuth = app.Configuration["Authorization:IsUse"];
var useAuthorization = useAuth.HasValue() && useAuth.Equals("true", StringComparison.OrdinalIgnoreCase);
if (useAuthorization)
{
@@ -293,16 +315,21 @@ public static async Task Use(this WebApplication webAp
{
webApplication.UseMiddleware();
- // Configure the HTTP request pipeline.
- webApplication.UseSwagger();
- webApplication.UseSwaggerUI();
-
- webApplication.UseHttpsRedirection();
- webApplication.UseAuthorization();
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
+ var useSwagger = config["Authorization:IsUse"];
+ var doUseSwagger = useSwagger.HasValue() && useSwagger.Equals("true", StringComparison.OrdinalIgnoreCase);
+ if (doUseSwagger)
+ {
+ webApplication.UseSwagger();
+ UseSwaggerUI(config, webApplication.UseSwaggerUI);
+ }
+
+ webApplication.UseHttpsRedirection();
+ webApplication.UseAuthorization();
+
using (var scope = webApplication.Services.CreateAsyncScope())
{
var dbbuilder = new DatabaseCreator();
diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
index c76aa62..fb3882a 100644
--- a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
core of database.
EasyMicroservices@gmail.com
core,cores,base,client,clients
diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
index 26b3f5e..3cd06ec 100644
--- a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net45;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
core contracts.
EasyMicroservices@gmail.com
core,cores,base,contract,contracts,dto,dtos
diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIConfigInfo.cs b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIConfigInfo.cs
new file mode 100644
index 0000000..75dd825
--- /dev/null
+++ b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIConfigInfo.cs
@@ -0,0 +1,12 @@
+namespace EasyMicroservices.Cores.Models;
+
+///
+///
+///
+public class SwaggerUIConfigInfo
+{
+ ///
+ ///
+ ///
+ public SwaggerUIEndpointInfo[] Endpoints { get; set; }
+}
diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIEndpointInfo.cs b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIEndpointInfo.cs
new file mode 100644
index 0000000..d5c5ee7
--- /dev/null
+++ b/src/CSharp/EasyMicroservices.Cores.Contracts/Models/SwaggerUIEndpointInfo.cs
@@ -0,0 +1,16 @@
+namespace EasyMicroservices.Cores.Models;
+
+///
+///
+///
+public class SwaggerUIEndpointInfo
+{
+ ///
+ ///
+ ///
+ public string Name { get; set; }
+ ///
+ ///
+ ///
+ public string Url { get; set; }
+}
diff --git a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
index 9863203..c6612ed 100644
--- a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net45;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
core of database.
EasyMicroservices@gmail.com
core,cores,base,database
diff --git a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
index 59a0fbc..1ccb766 100644
--- a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
@@ -4,7 +4,7 @@
net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
ef core of database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
index 7b21a17..cb00c61 100644
--- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
@@ -4,7 +4,7 @@
net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.0.95
+ 0.0.0.96
ef core of Relational database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore,Relational