支持.net 6,并处理分组显示 description的问题。

This commit is contained in:
luoyunchong 2021-11-10 23:08:20 +08:00
parent 089c238126
commit 233268c5e3
14 changed files with 112 additions and 15 deletions

View File

@ -6,8 +6,8 @@
[![nuget](https://img.shields.io/nuget/v/IGeekFan.AspNetCore.Knife4jUI.svg?style=flat-square)](https://www.nuget.org/packages/IGeekFan.AspNetCore.Knife4jUI) [![stats](https://img.shields.io/nuget/dt/IGeekFan.AspNetCore.Knife4jUI.svg?style=flat-square)](https://www.nuget.org/stats/packages/IGeekFan.AspNetCore.Knife4jUI?groupby=Version) [![GitHub license](https://img.shields.io/badge/license-Apache-blue.svg)](https://raw.githubusercontent.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI/master/LICENSE.txt)
## 相关依赖项
### [knife4j](https://gitee.com/xiaoym/knife4j)
- knife4j-vue-v3(不是vue3,而是swagger-ui-v3版本
### [knife4j](https://gitee.com/xiaoym/knife4j/tree/master/knife4j-vue)
- knife4j-vue
### [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
- Swashbuckle.AspNetCore.Swagger
- Swashbuckle.AspNetCore.SwaggerGen
@ -134,7 +134,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
### 🔎 效果图
运行项目,打开 https://localhost:5001/index.html#/home
![https://pic.downk.cc/item/5f2fa77b14195aa594ccbedc.jpg](https://pic.downk.cc/item/5f2fa77b14195aa594ccbedc.jpg)
![docs/home.jpg](docs/home.jpg)
### 更多配置请参考
@ -146,4 +146,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- [https://api.igeekfan.cn/swagger/index.html](https://api.igeekfan.cn/swagger/index.html)
- [https://github.com/luoyunchong/lin-cms-dotnetcore](https://github.com/luoyunchong/lin-cms-dotnetcore)
![image](https://pic.downk.cc/item/5f2fa97814195aa594cd5cfc.jpg)
![preview.jpg](docs/preview.jpg)

BIN
docs/home.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
docs/preview.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View File

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<Description>Middleware to expose an embedded version of the knife4j-vue-v3 from an ASP.NET Core application</Description>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<Description>Middleware to expose an embedded version of the knife4j-vue from an ASP.NET Core application</Description>
<NoWarn>$(NoWarn);1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>IGeekFan.AspNetCore.Knife4jUI</PackageId>
@ -11,14 +11,14 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/luoyunchong/IGeekFan.AspNetCore.Knife4jUI.git</RepositoryUrl>
<RootNamespace>IGeekFan.AspNetCore.Knife4jUI</RootNamespace>
<Version>0.0.10</Version>
<Version>0.0.11</Version>
<Company />
<Authors>igeekfan;xiaoym;</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Copyright>Apache License 2.0</Copyright>
<PackageLicenseExpression></PackageLicenseExpression>
<AssemblyVersion>0.0.10.0</AssemblyVersion>
<FileVersion>0.0.10.0</FileVersion>
<AssemblyVersion>0.0.11.0</AssemblyVersion>
<FileVersion>0.0.11.0</FileVersion>
</PropertyGroup>
<!-- Using SourceLink -->
@ -31,7 +31,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.0" />

View File

@ -22,7 +22,7 @@
<link href=knife4j/js/chunk-adb9e944.b888f4bd.js rel=prefetch>
<link href=knife4j/css/app.284871fa.css rel=preload as=style>
<link href=knife4j/css/chunk-vendors.3f2387de.css rel=preload as=style>
<link href=knife4j/js/app.703cb2b2.js rel=preload as=script>
<link href=knife4j/js/app.6735d201.js rel=preload as=script>
<link href=knife4j/js/chunk-vendors.90e8ba20.js rel=preload as=script>
<link href=knife4j/css/chunk-vendors.3f2387de.css rel=stylesheet>
<link href=knife4j/css/app.284871fa.css rel=stylesheet>
@ -32,7 +32,7 @@
<noscript><strong>We're sorry but knife4j-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id=app></div>
<script src=knife4j/js/chunk-vendors.90e8ba20.js></script>
<script src=knife4j/js/app.703cb2b2.js></script>
<script src=knife4j/js/app.6735d201.js></script>
<script>
window.onload = function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,92 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Knife4j-OAuth2</title>
<script src="jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
function OAuth2(url){
this.url=url;
this.code=null;
this.accessToken=null;
this.tokenType=null;
this.state=null;
//缓存在localStorage中的对象
this.cacheValue=null;
}
OAuth2.prototype.init=function(){
var local=this.url;
this.code=this.getKey("code",local,"");
this.accessToken=this.getKey("access_token",local,"");
this.tokenType=this.getKey("token_type",local,"Bearer");
this.state=this.getKey("state",local);
if(window.localStorage){
var value=window.localStorage.getItem(this.state);
if(this.strNotBlank(value)){
this.cacheValue=JSON.parse(value);
}
}
}
OAuth2.prototype.auth=function(){
if(this.strNotBlank(this.code)){
this.authorizationCode();
}else{
this.implicit();
}
}
OAuth2.prototype.getKey=function(key,str,defaultValue){
var reg=new RegExp(".*?"+key+"=(.*?)(&.*)?$","ig");
var val=defaultValue;
if(reg.test(str)){
val=RegExp.$1;
}
return val;
}
OAuth2.prototype.strNotBlank=function(str){
var flag = false;
if ( str != undefined &&str != null &&str != "") {
flag = true;
}
return flag;
}
OAuth2.prototype.implicit=function(){
this.cacheValue.accessToken=this.tokenType+" "+this.accessToken;
this.cacheValue.tokenType=this.tokenType;
this.cacheValue.granted=true;
window.localStorage.setItem(this.state,JSON.stringify(this.cacheValue))
window.close();
}
OAuth2.prototype.authorizationCode=function(){
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
"client_id":this.cacheValue.clientId,
"client_secret":this.cacheValue.clientSecret
}
$.post(url,params,function(data){
if(data!=null&&data!=undefined) {
that.cacheValue.accessToken=data.token_type+" "+data.access_token;
that.cacheValue.tokenType=data.token_type;
that.cacheValue.granted=true;
window.localStorage.setItem(that.state,JSON.stringify(that.cacheValue))
window.close();
}
})
}
var oauth=new OAuth2(window.location.href);
oauth.init();
oauth.auth();
})
</script>
</body>
</html>

View File

@ -11,6 +11,7 @@
</PropertyGroup>
<ItemGroup>
<!--<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.9" />-->
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
</ItemGroup>

View File

@ -1,4 +1,4 @@
using IGeekFan.AspNetCore.Knife4jUI;
using IGeekFan.AspNetCore.Knife4jUI;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Controllers;
@ -28,7 +28,7 @@ namespace Knife4jUIDemo
c.SwaggerDoc("v1", new OpenApiInfo { Title = "API V1", Version = "v1" });
c.AddServer(new OpenApiServer()
{
Url = "",
//Url = "http://localhost:81/admin/",
Description = "vvv"
});
c.CustomOperationIds(apiDesc =>