GithubHelp home page GithubHelp logo

shakann / nswag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ricosuter/nswag

0.0 2.0 0.0 6.82 MB

The Swagger API toolchain for .NET, Web API and TypeScript.

Home Page: http://NSwag.org

License: Microsoft Public License

C# 97.89% Batchfile 0.03% ASP 0.01% TypeScript 1.95% HTML 0.03% PowerShell 0.09%

nswag's Introduction

NSwag: The Swagger API toolchain for .NET, Web API and TypeScript

NuGet Version Build status Build status Gitter Issues StackOverflow ![Donate](https://img.shields.io/badge/donate-via PayPal-green.svg?style=flat)

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

The project combines the functionality of Swashbuckle (Swagger generation) and AutoRest (client generation) in one tool chain. This way a lot of incompatibilites can be avoided and features which are not well described by the Swagger 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 maintained and developed by Rico Suter and other contributors.

Ways to use the toolchain:

Swagger Generators:

Code Generators:

Downloads

NuGet Packages

  • NSwag.Core (PCL 259): The Swagger reader and writer classes (Source Code)
  • NSwag.Annotations (PCL 259): Attributes to decorate Web API controllers to control the Swagger generation (Source Code)
  • NSwag.CodeGeneration (PCL 259): Classes to generate Swagger specifications from Web API controllers and C# and TypeScript clients (Source Code)
  • NSwag.AssemblyLoader (.NET 4.5+): Classes to load assemblies in an isolated AppDomain and generate Swagger specs from Web API controllers
  • 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
  • NSwag.AspNetCore (.NETStandard 1.6 and .NET 4.5.1+):
  • NSwag.AspNet.Owin (.NET 4.5+): OWIN Middlewares for serving Swagger specifications and Swagger UI
  • NSwagStudio (Chocolatey): Package to install the NSwagStudio and command line tools via Chocolatey

Usage in C#

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

var swaggerSettings = new WebApiToSwaggerGeneratorSettings();
var swaggerGenerator = new WebApiToSwaggerGenerator(swaggerSettings);

var service = swaggerGenerator.GenerateForController<PersonsController>();

var clientSettings = new SwaggerToCSharpClientGeneratorSettings 
{
    ClassName = "MyClass",
    Namespace = "MyNamespace"
};
var clientGenerator = new SwaggerToCSharpClientGenerator(service, 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:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.