The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
NSwag | NJsonSchema | Apimundo | Namotion.Reflection :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.
The project is developed and maintained by Rico Suter and other contributors.
JQueryCallbacksJQueryPromisesAngularJSAngularFetch (use this template in your React/Redux app)Aurelia (based on the Fetch template)Axios (preview)dotnet nswag)<DotNetCliToolReference Include="NSwag.ConsoleCore" Version="..." />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).
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 servTypeScript client: `format: date` query and path parameters are serialised with `toISOString()` instead of a date-only string
Default c# type for "number" in Swagger Spec
Exclude API paths in CSharp Client generation
oneOf is not produce the right results for C# generated classes?
A custom string `format` silently degrades to `string` with no way to map it
CSharp Client "Content-Disposition"-Header in request is generated invalid
Property of type double is parsed to decimal
NSwag generated C# clients fail to set Content-Language header as it must be set on Content headers
Typescript generated client does not include FileParameter when its in an Array
NSwag Studio: Option to store downloaded OpenAPI specification externally instead of embedding it in *.nswag file