IGeekFan.AspNetCore.Knife4jUI 0.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package IGeekFan.AspNetCore.Knife4jUI --version 0.0.6                
NuGet\Install-Package IGeekFan.AspNetCore.Knife4jUI -Version 0.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IGeekFan.AspNetCore.Knife4jUI --version 0.0.6                
#r "nuget: IGeekFan.AspNetCore.Knife4jUI, 0.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IGeekFan.AspNetCore.Knife4jUI as a Cake Addin
#addin nuget:?package=IGeekFan.AspNetCore.Knife4jUI&version=0.0.6

// Install IGeekFan.AspNetCore.Knife4jUI as a Cake Tool
#tool nuget:?package=IGeekFan.AspNetCore.Knife4jUI&version=0.0.6                

IGeekFan.AspNetCore.Knife4jUI

一个swagger ui 库:knife4j UI,支持 .NET Core3.0+或.NET Standard2.0。

nuget stats GitHub license

相关依赖项

knife4j

  • knife4j-vue-v3(不是vue3,而是swagger-ui-v3版本)

Swashbuckle.AspNetCore

  • Swashbuckle.AspNetCore.Swagger
  • Swashbuckle.AspNetCore.SwaggerGen

Demo

📚 快速开始

🚀安装包

1.Install the standard Nuget package into your ASP.NET Core application.

Package Manager : Install-Package IGeekFan.AspNetCore.Knife4jUI
CLI : dotnet add package IGeekFan.AspNetCore.Knife4jUI

2.In the ConfigureServices method of Startup.cs, register the Swagger generator, defining one or more Swagger documents.

using Microsoft.AspNetCore.Mvc.Controllers
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using IGeekFan.AspNetCore.Knife4jUI;

🚁 ConfigureServices

3.服务配置,CustomOperationIds和AddServer是必须的。

   services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1",new OpenApiInfo{Title = "API V1",Version = "v1"});
        c.AddServer(new OpenApiServer()
        {
            Url = "",
            Description = "vvv"
        });
        c.CustomOperationIds(apiDesc =>
        {
            var controllerAction = apiDesc.ActionDescriptor as ControllerActionDescriptor;
            return  controllerAction.ControllerName+"-"+controllerAction.ActionName;
        });
    });

💪 Configure

  1. 中间件配置
app.UseSwagger();

app.UseKnife4UI(c =>
{
    c.RoutePrefix = ""; // serve the UI at root
    c.SwaggerEndpoint("/v1/api-docs", "V1 Docs");
});

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapSwagger("{documentName}/api-docs");
});

5.更多功能

为文档添加注释 在项目上右键--属性--生成

alternate text is missing from this package README image

在AddSwaggerGen方法中添加如下代码

c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "SwaggerDemo.xml"),true);

最后一个参数设置为true,代表启用控制器上的注释

运行后如看不到控制器上注释显示,请点开文档管理->个性化设置,开启分组tag显示description说明属性

alternate text is missing from this package README image

🔎 效果图

运行项目,打开 https://localhost:5001/index.html#/home

https://pic.downk.cc/item/5f2fa77b14195aa594ccbedc.jpg

更多配置请参考

更多项目

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (39)

Showing the top 5 NuGet packages that depend on IGeekFan.AspNetCore.Knife4jUI:

Package Downloads
Coder.Extension

Coder扩展程序,包含:AutoMapper,Log,CsRedis,Swagger(Knife4j),Cors,Autofac,Hangfire,TimedJob,CAP,SqlSugar,Polly(超时,重试,熔断,降级)等扩展服务和中间件。

Mall3s.ServiceFabric

Package Description

Magic.Bfw.Extension

具有权限管理功能,支持多库操作的基础框架

MSFactory.ToolKits

Package Description

TDAI.Framework

核心框架类库

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on IGeekFan.AspNetCore.Knife4jUI:

Repository Stars
luoyunchong/lin-cms-dotnetcore
😃A simple and practical CMS implemented by .NET + FreeSql;前后端分离、Docker部署、OAtuh2授权登录、自动化部署DevOps、自动同步至Gitee、代码生成器、仿掘金专栏
luoyunchong/dotnetcore-examples
about learning DotNetCore via examples. DotNetCore 教程、技术栈示例代码,快速简单上手教程。
hzy-6/hzy-admin
前后端分离权限管理系统基架! 数据权限、按钮权限、动态菜单、动态任务调度、动态WebApi、定时标记 [Scheduled("0/5 * * * * ?")] 、代码生成
Version Downloads Last updated
0.0.16 119,855 8/3/2023
0.0.14 11,994 7/19/2023
0.0.13 98,184 11/10/2022
0.0.12 26,717 8/16/2022
0.0.11 101,347 11/11/2021
0.0.10 3,470 10/22/2021
0.0.9 2,899 9/2/2021
0.0.8 276,924 10/23/2020
0.0.7 6,462 8/24/2020
0.0.6 570 8/24/2020
0.0.4 1,219 8/12/2020
0.0.2 595 8/11/2020
0.0.1 700 8/9/2020