diff --git a/src/IGeekFan.AspNetCore.Knife4jUI/IGeekFan.AspNetCore.Knife4jUI.csproj b/src/IGeekFan.AspNetCore.Knife4jUI/IGeekFan.AspNetCore.Knife4jUI.csproj index fcda3f7..7f566c5 100644 --- a/src/IGeekFan.AspNetCore.Knife4jUI/IGeekFan.AspNetCore.Knife4jUI.csproj +++ b/src/IGeekFan.AspNetCore.Knife4jUI/IGeekFan.AspNetCore.Knife4jUI.csproj @@ -1,39 +1,46 @@ ๏ปฟ - netstandard2.0;netcoreapp3.0 + netstandard2.0;netcoreapp3.1;net5.0 Middleware to expose an embedded version of the knife4j-vue-v3 from an ASP.NET Core application $(NoWarn);1591 true - + IGeekFan.AspNetCore.Knife4jUI swagger;documentation;discovery;help;webapi;aspnet;aspnetcore https://github.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI git https://github.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI.git IGeekFan.AspNetCore.Knife4jUI - 0.0.7 + 0.0.9 igeekfan;xiaoym; true Apache License 2.0 - 0.0.8.0 - 0.0.8.0 + 0.0.9.0 + 0.0.9.0 + + + + + true + snupkg true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + - + - + - + diff --git a/src/IGeekFan.AspNetCore.Knife4jUI/Knife4UIOptions.cs b/src/IGeekFan.AspNetCore.Knife4jUI/Knife4UIOptions.cs index b87d81e..ac971c1 100644 --- a/src/IGeekFan.AspNetCore.Knife4jUI/Knife4UIOptions.cs +++ b/src/IGeekFan.AspNetCore.Knife4jUI/Knife4UIOptions.cs @@ -136,6 +136,8 @@ namespace IGeekFan.AspNetCore.Knife4jUI public string Url { get; set; } public string Name { get; set; } + + public string SwaggerVersion { get; set; } = "3.0"; } public enum ModelRendering diff --git a/src/IGeekFan.AspNetCore.Knife4jUI/Knife4jUIMiddleware.cs b/src/IGeekFan.AspNetCore.Knife4jUI/Knife4jUIMiddleware.cs index 7b2bb6b..de12ba7 100644 --- a/src/IGeekFan.AspNetCore.Knife4jUI/Knife4jUIMiddleware.cs +++ b/src/IGeekFan.AspNetCore.Knife4jUI/Knife4jUIMiddleware.cs @@ -14,8 +14,8 @@ using System.Text.Json; using System.Text.Json.Serialization; using Microsoft.AspNetCore.Hosting; using System.Collections.Generic; -#if NETCOREAPP3_0 -using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment; +#if NETSTANDARD2_0 +using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment; #endif namespace IGeekFan.AspNetCore.Knife4jUI { @@ -29,7 +29,7 @@ namespace IGeekFan.AspNetCore.Knife4jUI public Knife4jUIMiddleware( RequestDelegate next, - IHostingEnvironment hostingEnv, + IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory, Knife4UIOptions options) { @@ -66,7 +66,7 @@ namespace IGeekFan.AspNetCore.Knife4jUI return; } - if (httpMethod == "GET" && Regex.IsMatch(path, $"^/v3/api-docs/swagger-config$")) + if (httpMethod == "GET" && Regex.IsMatch(path, $"^/swagger-resources$")) { await RespondWithConfig(httpContext.Response); return; @@ -77,12 +77,12 @@ namespace IGeekFan.AspNetCore.Knife4jUI private async Task RespondWithConfig(HttpResponse response) { - await response.WriteAsync(JsonSerializer.Serialize(_options.ConfigObject, _jsonSerializerOptions)); + await response.WriteAsync(JsonSerializer.Serialize(_options.ConfigObject.Urls, _jsonSerializerOptions)); } private StaticFileMiddleware CreateStaticFileMiddleware( RequestDelegate next, - IHostingEnvironment hostingEnv, + IWebHostEnvironment hostingEnv, ILoggerFactory loggerFactory, Knife4UIOptions options) { diff --git a/src/IGeekFan.AspNetCore.Knife4jUI/index.html b/src/IGeekFan.AspNetCore.Knife4jUI/index.html index 06b2a46..fc75ae8 100644 --- a/src/IGeekFan.AspNetCore.Knife4jUI/index.html +++ b/src/IGeekFan.AspNetCore.Knife4jUI/index.html @@ -6,17 +6,33 @@ %(DocumentTitle) - - - - + + + + + + + + + + + + + + + + + + + + %(HeadContent)
- - + +