GitRead 中文社区
首页趋势排行榜原创文章严选周刊
更多资源
新手训练营
精选专题热门话题GitHub 文档资源精选实战指南

NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.

  • 语言C#
  • 默认分支master
  • 大小63.8 MB
  • 更新9月8日
  • Issues2.0k
在 GitHub 打开
avatarRicoSuter

项目介绍

RicoSuter/NSwag 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 MIT License 许可证,目前获得 7.4k 个 Star、1.3k 次 Fork。

仓库全名
RicoSuter/NSwag

README 摘要

NSwag: The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript NSwag | NJsonSchema | Apimundo | Namotion.Reflection :pointright: Announcing Apimundo: An API documentation system based on NSwag and NJsonSchema :pointleft: NSwag is a Swagger/OpenAPI 2.0 and 3.0 toolchain for .NET, .NET Core, Web API, ASP.NET Core, TypeScript (jQuery, AngularJS, Angular 2+, Aurelia, KnockoutJS and more) and other platforms,…

完整内容见 GitHub 原始 README 或本页 。

常见问题

NSwag 用什么语言开发?

主要使用 C# 编写,采用 MIT License 许可证,目前有 7.4k 个 Star。

NSwag 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 NSwag 的源码?

可以直接克隆仓库:git clone https://github.com/RicoSuter/NSwag.git,默认分支为 master;安装与运行步骤见仓库 README。

NSwag 最近还在维护吗?

仓库最近一次更新为 9月8日,当前有 2.0k 个未关闭 Issue;Star 数为 7.4k,可作为社区活跃度的参考。

本页面展示项目元数据与原始 README,GitRead 中文社区 编辑团队负责选题收录。

相关仓库

2dust/v2rayN avatar
v2rayN2dust
14 小时前
120.4k
16.3k
19

一个适用于 Windows、Linux 和 macOS 的 GUI 客户端,支持 Xray、sing-box 等

proxyshadowsockssocks5+8
C#
50.0 MB
0
详情
shadowsocks/shadowsocks-windows avatar
shadowsocks-windowsshadowsocks
2025年1月1日
59.5k
15.7k
187

shadowsocks 的 C# 移植版

c-sharpproxyshadowsocks
C#
13.2 MB
0
详情
jellyfin/jellyfin avatar
jellyfinjellyfin
20 小时前
59.2k
5.8k
884

自由软件媒体系统 - 服务器后端与 API

csharpdotnethacktoberfest+1
C#
77.3 MB
0
详情
PowerShell/PowerShell avatar
PowerShellPowerShell
14 小时前
56.1k
8.3k
1.3k

适用于所有系统的 PowerShell!

command-linehacktoberfestlinux+5
C#
109.8 MB
0
详情
files-community/Files avatar
Filesfiles-community
1 天前
46.6k
3.0k
454

一款现代文件管理器,帮助用户整理文件和文件夹。

alternativescsharpcustomization+17
C#
283.0 MB
0
详情
ShareX/ShareX avatar
ShareXShareX
1 天前
40.9k
4.0k
618

ShareX 是一款免费开源应用,用户只需按一次键即可捕获或录制屏幕任意区域。它还支持将图像、文本及多种文件类型上传至多种目标位置。

avaloniacapturecolor-picker+17
C#
157.0 MB
0
详情
huiyadanli/RevokeMsgPatcher avatar
RevokeMsgPatcherhuiyadanli
2 天前
39.2k
4.1k
55

用于微信/QQ/TIM 的十六进制编辑器 - PC版微信/QQ/TIM防撤回补丁(我已经看到了,撤回也没用了)

patchpcwindows+7
C#
3.6 MB
0
详情
dotnet/aspnetcore avatar
aspnetcoredotnet
1 天前
38.5k
11.4k
3.9k

ASP.NET Core 是一个跨平台 .NET 框架,用于在 Windows、Mac 或 Linux 上构建现代基于云的 Web 应用程序。

dotnetaspnetcorehacktoberfest+1
C#
404.3 MB
0
详情

关于

angularaspnetaspnetcoreaureliacodegencsharpdotnetnswagopenapiswaggertypescriptwebapi
  • MIT License
  • 7.4k Stars
  • 1.3k Forks
  • 154 Watching

简要分析

热度分
10126
价值分
4728
活跃状态
活跃
GitHub

语言占比

Batchfile
C#
HTML
JavaScript
Liquid
PowerShell
Shell
TypeScript

Release

  • NSwag v14.7.1 (NJsonSchema v11.6.1)4月21日
  • NSwag v14.7.0 (NJsonSchema v11.6.0)4月9日
  • NSwag v14.6.3 (NJsonSchema v11.5.2)2025年11月21日
  • NSwag v14.6.2 (NJsonSchema v11.5.2)2025年11月5日
  • NSwag v14.6.1 (NJsonSchema v11.5.1)2025年10月1日

贡献者

RicoSuterRicoSuterlahmalahmagrovesNLgrovesNLdependabot[bot]dependabot[bot]paulomorgadopaulomorgadoShaKannShaKanndougbudougbudgioulakisdgioulakistrejjamtrejjampranavkmpranavkmEm1ss1oNEm1ss1oNkrisztiankocsiskrisztiankocsis

NSwag: The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript

NSwag | NJsonSchema | Apimundo | Namotion.Reflection

NuGet Version npm NuGet Version Preview build Discord StackOverflow Wiki Backers on Open Collective Sponsors on Open Collective

:point_right: Announcing Apimundo: An API documentation system based on NSwag and NJsonSchema :point_left:

NSwag is a Swagger/OpenAPI 2.0 and 3.0 toolchain for .NET, .NET Core, Web API, ASP.NET Core, TypeScript (jQuery, AngularJS, Angular 2+, Aurelia, KnockoutJS and more) and other platforms, written in C#. The OpenAPI/Swagger specification uses JSON and JSON Schema to describe a RESTful web API. The NSwag project provides tools to generate OpenAPI specifications from existing ASP.NET Web API controllers and client code from these OpenAPI specifications.

The project combines the functionality of Swashbuckle (OpenAPI/Swagger generation) and AutoRest (client generation) in one toolchain (these two libs are not needed). This way a lot of incompatibilites can be avoided and features which are not well described by the OpenAPI specification or JSON Schema are better supported (e.g. inheritance, enum and reference handling). The NSwag project heavily uses NJsonSchema for .NET for JSON Schema handling and C#/TypeScript class/interface generation.

ToolchainDiagram

The project is developed and maintained by Rico Suter and other contributors.

Features

  • Generate Swagger 2.0 and OpenAPI 3.0 specifications from C# ASP.NET (Core) controllers
  • Serve the specs via ASP.NET (Core) middleware, optionally with Swagger UI or ReDoc
  • Generate C# or TypeScript clients/proxies from these specs
  • Everything can be automated via CLI (distributed via NuGet tool or build target; or NPM)
  • CLI configured via JSON file or NSwagStudio Windows UI

Ways to use the toolchain

  • Simple to use Windows GUI, NSwagStudio
  • By using the OpenAPI or OpenAPI UI OWIN and ASP.NET Core Middlewares (also serves the Swagger UI) (recommended)
  • Via command line (Windows, Mac and Linux support through Mono or .NET Core console binary, also via NPM package)
  • In your C# code, via NuGet
  • In your MSBuild targets
  • With ServiceProjectReference tags in your .csproj (preview)
  • In your Azure V2 Functions (external project, might not use latest NSwag version)

Tutorials

  • Add NSwag to your ASP.NET Core app
  • Integrate the NSwag toolchain into your ASP.NET Web API project
  • Generate an Angular TypeScript client from an existing ASP.NET Web API web assembly
  • Video Tutorial: How to integrate NSwag into your ASP.NET Core Web API project (5 mins)

OpenAPI/Swagger Generators

  • ASP.NET Web API assembly to OpenAPI (supports .NET Core)
    • AspNetCoreOpenApiDocumentGenerator
    • WebApiOpenApiDocumentGenerator
      • Generates an OpenAPI specification for Web API controllers
    • WebApiToOpenApiCommand
      • Generates an OpenAPI specification for controllers in an external Web API assembly
      • Also supports loading of .NET Core assemblies
    • TypesToOpenApiCommand
      • Generates an OpenAPI specification containing only types from .NET assemblies

Code Generators

  • CSharp Client
    • CSharpClientGenerator
      • Generates C# clients from an OpenAPI specification
      • Generates POCOs or classes implementing INotifyPropertyChanged supporting DTOs
      • The generated clients can be used with full .NET, .NET Core, Xamarin and .NET Standard 1.4 in general
  • CSharp Controllers (contract first/schema first development)
    • CSharpControllerGenerator
      • Generates Web API Controllers based on an OpenAPI specification (ASP.NET Web API and ASP.NET Core)
  • TypeScript Client
    • TypeScriptClientGenerator
      • Generates TypeScript clients from an OpenAPI specification
      • Available templates/supported libraries:
        • JQuery with Callbacks, JQueryCallbacks
        • JQuery with promises JQueryPromises
        • AngularJS using $http, AngularJS
        • Angular (v2+) using the http service, Angular
        • window.fetch API and ES6 promises, Fetch (use this template in your React/Redux app)
        • Aurelia using the HttpClient from aurelia-fetch-client, Aurelia (based on the Fetch template)
        • Axios (preview)

Downloads

  • Download latest NSwagStudio MSI installer (NSwagStudio.msi) (Windows Desktop application)
  • Download latest NSwag command line tools and NSwagStudio (NSwag.zip)

NPM Packages

  • NSwag: Command line tools (.NET and .NET Core) distributed as NPM package

NuGet Packages

Specification
  • NSwag.Core
    • The OpenAPI/Swagger reader and writer classes, see OpenApiDocument (.NET Standard 1.0 / 2.0 and .NET 4.5)
  • NSwag.Core.Yaml (.NET Standard 1.3 / 2.0 and .NET 4.5)
    • Extensions to read and write YAML OpenAPI specifications
  • NSwag.Annotations (.NET Standard 1.0 / 2.0 and .NET 4.5)
    • Attributes to decorate Web API controllers to control the OpenAPI generation
OpenAPI generation
  • NSwag.Generation (.NET Standard 1.0 / 2.0 and .NET 4.5)
    • Classes to generate OpenAPI specifications
  • NSwag.Generation.WebApi (.NET Standard 1.0 / 2.0 and .NET 4.5)
    • Classes to generate OpenAPI specifications from Web API controllers, see WebApiOpenApiDocumentGenerator
  • NSwag.Generation.AspNetCore (.NET Standard 1.6 / 2.0 and .NET 4.5.1)
    • (Experimental) Classes to generate OpenAPI specifications from ASP.NET Core MVC controllers using the ApiExplorer
Code generation
  • NSwag.CodeGeneration (.NET Standard 1.3 / 2.0 / .NET 4.5.1)
    • Base classes to generate clients from OpenAPI specifications
  • NSwag.CodeGeneration.CSharp (.NET Standard 1.3 and .NET 4.5.1)
    • Classes to generate C# clients from OpenAPI specifications, see CSharpClientGenerator and CSharpControllerGenerator
  • NSwag.CodeGeneration.TypeScript (.NET Standard 1.3 and .NET 4.5.1)
    • Classes to generate TypeScript clients from OpenAPI specifications, see TypeScriptClientGenerator
ASP.NET and ASP.NET Core
  • NSwag.AspNetCore (.NET Standard 1.6 / 2.0 and .NET 4.5.1+)
  • NSwag.AspNet.Owin (.NET 4.5+)
    • ASP.NET Core/OWIN middlewares for serving OpenAPI specifications and Swagger UI
  • NSwag.AspNet.WebApi (.NET 4.5+)
    • ASP.NET Web API filter which serializes exceptions (JsonExceptionFilterAttribute)
Frontends
  • NSwag.AssemblyLoader (.NET Standard 1.6 / 2.0 and .NET 4.5.1):
    • Classes to load assemblies in an isolated AppDomain and generate OpenAPI specs from Web API controllers
  • NSwag.Commands (.NET Standard 1.6 / 2.0 and .NET 4.5.1+):
    • Commands for the command line tool implementations and UI
  • NSwag.MSBuild (MSBuild .targets):
    • Adds a .targets file to your Visual Studio project, so that you can run the NSwag command line tool in an MSBuild target, see MSBuild
  • NSwag.ConsoleCore (.NET Core 1.0, 1.1, 2.0, 2.1 and 2.2):
    • Command line tool for .NET Core (dotnet nswag)
    • <DotNetCliToolReference Include="NSwag.ConsoleCore" Version="..." />
  • NSwagStudio (Chocolatey, Windows):
    • Package to install the NSwagStudio and command line tools via Chocolatey
CI NuGet Feed

https://www.myget.org/F/nswag/api/v3/index.json

The NuGet packages may require the Microsoft.NETCore.Portable.Compatibility package on .NET Core/UWP targets (if mscorlib is missing).

LayerDiagram

Usage in C#

To register the middlewares to generate an OpenAPI spec and render the UI, register NSwag in Startup.cs:

public class Startup
{
    ...

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddOpenApiDocument(); // add OpenAPI v3 document
//      services.AddSwaggerDocument(); // add Swagger v2 document
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        ...

        app.UseOpenApi(); // serve OpenAPI/Swagger documents
        app.UseSwaggerUi(); // serve Swagger UI
        app.UseReDoc(); // serve ReDoc UI
    }
}

The following code shows how to read an OpenAPI/Swagger specification and generate C# client classes to call the described web services:

var document = await OpenApiDocument.FromFileAsync("openapi.json");
var clientSettings = new CSharpClientGeneratorSettings 
{
    ClassName = "MyClass",
    CSharpGeneratorSettings = 
    {
        Namespace = "MyNamespace"
    }
};

var clientGenerator = new CSharpClientGenerator(document, clientSettings);
var code = clientGenerator.GenerateFile();

Check out the project Wiki for more information.

NSwagStudio

The generators can be used in a comfortable and simple Windows GUI called NSwagStudio:

Sponsors, support and consulting

Companies or individuals which paid a substantial amount for implementing, fixing issues, support or sponsoring are listed below. Thank you for supporting this project! You can also become a financial contributor:

  • Sponsor main contributor Rico Suter via GitHub
  • Sponsor project via Open Collective for NSwag

Please contact Rico Suter for paid consulting and support.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

Top sponsors:

Sponsors:

Backers

Thank you to all our backers!

评论

登录 后发表评论
暂无评论
GitRead 中文社区
深度解读 · 趋势洞察 · 价值精选

关于

关于我们联系我们编辑准则收录标准赞赏人员

发现

技术趋势新手训练营资源精选实战指南精选专题热门话题GitHub 文档

条款

隐私政策服务条款网站地图
26.9万收录项目
6.3万中文话题
155精选专题
发现技术价值,连接开源智慧
© 2026 GitRead · GitHub 中文社区 本站与 GitHub, Inc. 无隶属关系;GitHub 是 GitHub, Inc. 的商标。