All Projects → RicoSuter → Nswag

RicoSuter / Nswag

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

Programming Languages

typescript
32286 projects
C#
18002 projects
Liquid
124 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to Nswag

Webapiclient
An open source project based on the HttpClient. You only need to define the c# interface and modify the related features to invoke the client library of the remote http interface asynchronously.
Stars: ✭ 1,618 (-66.47%)
Mutual labels:  swagger, openapi, webapi
Swagger Axios Codegen
swagger client to use axios and typescript
Stars: ✭ 143 (-97.04%)
Mutual labels:  swagger, openapi, codegen
Aspnetcore Ddd
Full ASP.NET Core 3.1 LTS application with DDD, CQRS and Event Sourcing
Stars: ✭ 88 (-98.18%)
Mutual labels:  swagger, webapi, aspnetcore
Aspnet Api Versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,154 (-55.36%)
Mutual labels:  webapi, aspnetcore, aspnet
aspnet-api-versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,396 (-50.34%)
Mutual labels:  aspnetcore, aspnet, webapi
Swagger Node Codegen
An OpenAPI 3.x/Swagger 2 code generator for Node.js
Stars: ✭ 189 (-96.08%)
Mutual labels:  swagger, openapi, codegen
Netcoreblockly
.NET Core API to Blockly - generate from WebAPI, Swagger, OData, GraphQL =>
Stars: ✭ 121 (-97.49%)
Mutual labels:  swagger, openapi, webapi
Guardrail
Principled code generation from OpenAPI specifications
Stars: ✭ 396 (-91.79%)
Mutual labels:  swagger, openapi, codegen
MinimalApi
ASP.NET Core 7.0 - Minimal API Example - Todo API implementation using ASP.NET Core Minimal API, Entity Framework Core, Token authentication, Versioning, Unit Testing, Integration Testing and Open API.
Stars: ✭ 156 (-96.77%)
Mutual labels:  aspnetcore, openapi, webapi
Openapi Codegen
OpenAPI 3.0 CodeGen plus Node.js minus the Java and emojis
Stars: ✭ 224 (-95.36%)
Mutual labels:  swagger, openapi, codegen
SparkTodo
TodoList WebApi Powered by ASP.Net Core and JWT token auth
Stars: ✭ 37 (-99.23%)
Mutual labels:  aspnetcore, swagger, webapi
Openapi Typescript Codegen
NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
Stars: ✭ 249 (-94.84%)
Mutual labels:  swagger, openapi, codegen
Aspnetcore Webapi Course
Professional REST API design with ASP.NET Core 3.1 WebAPI
Stars: ✭ 323 (-93.31%)
Mutual labels:  swagger, webapi
Aspnetcore Webapi Sample
This is a sample ASP.NET Core WebAPI
Stars: ✭ 310 (-93.58%)
Mutual labels:  webapi, aspnetcore
Swag
Automatically generate RESTful API documentation with Swagger 2.0 for Go.
Stars: ✭ 5,173 (+7.21%)
Mutual labels:  swagger, openapi
Autorest
OpenAPI (f.k.a Swagger) Specification code generator. Supports C#, PowerShell, Go, Java, Node.js, TypeScript, Python
Stars: ✭ 3,607 (-25.24%)
Mutual labels:  swagger, openapi
Light 4j
A fast, lightweight and more productive microservices framework
Stars: ✭ 3,303 (-31.54%)
Mutual labels:  swagger, openapi
Pyswagger
An OpenAPI (fka Swagger) client & converter in python, which is type-safe, dynamic, spec-compliant.
Stars: ✭ 326 (-93.24%)
Mutual labels:  swagger, openapi
Pode
Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
Stars: ✭ 329 (-93.18%)
Mutual labels:  swagger, openapi
Meiam.system
.NET 5 / .NET Core 3.1 WebAPI + Vue 2.0 + RBAC 企业级前后端分离权限框架
Stars: ✭ 340 (-92.95%)
Mutual labels:  swagger, webapi

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

NSwag | NJsonSchema | Apimundo | Namotion.Reflection

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

👉 Announcing Apimundo: An API documentation system based on NSwag and NJsonSchema 👈

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:

Ways to use the toolchain:

Tutorials:

OpenAPI/Swagger Generators:

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 a OpenAPI specification (ASP.NET Web API and ASP.NET Core)
  • TypeScript Client
    • TypeScriptClientGenerator
      • Generates TypeScript clients from a 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

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:

Code generation:

ASP.NET and ASP.NET Core:

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 a 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.UseSwaggerUi3(); // 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:

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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].