You can get the latest WPF & console client downloads (& all historic ones too) in Releases.
nSwagger is a set of tools for developers who use Microsoft languages (C# & TypeScript) which aim to ease the experience with REST APIs documented using Swagger 2.0.
For C#, nSwagger offers a codegen tool built using the Roslyn compiler and aims to produce a full client library for as the output.
For TypeScript as there is already a great JS codegen, we are focused on generating definations to make it easier to work with the JS from the codegen while working inside of TypeScript.
You can see some examples of the outputs in our Examples folder.
The core of the project is a library which will allow you to pass in URLs or file paths to Swagger definations and have that generate a C# class reflecting the defination (this is called the SpecificationClass
), which can then be used to generate other outputs.
Included in the Core Library is also a C# Code Generator which takes the SpecificationClass
and produces C# file, which can call the API endpoint.
Included in the Core Library is also a TypeScript defination generator which takes the SpecificationClass
which add to the JS codegen for Swagger by providing a TypeScript definations for the requests & responses.
To make it easier to work with for developers we are building a number of clients which will expose the functionality. Ideally you should just download the client of your choice and generate the files you need.
The first client for the core library is a console application which you can run and produce the code from the Swagger files. This is available now in the Releases.
A GUI client which offers similar functionality to the console client but with a GUI. This is available now in the Releases.
The ultimate client is to add an extension to Visual Studio, the goal of this is to be able to right click a project and have "Add Swagger Reference" appear, which will let you easily consume a Swagger endpoint.
If you are going to consume the core library or the C# code gen, you will need to add Using this class requires the use of JSON.NET to your project.
If you are just using the client then you only need .NET 4.6.1 (or later) installed.
These are items we plan on resolving asap.
As we figure out the right structures the generated code may change between values.
For C#, the endpoint must support JSON requests/responses, as this is all that is supported by the library.
For C#, the Swagger defination provides a LOT of information for validating the data. It would be great to have the data provided to the calls validated client side before the call is made.
For C#, The only authentication currently supported is OAuth2.
We would love you help with this project! So please feel free to fork the code and do a pull request!
Important to note is our Code License (MIT) and our Contributor License Agreement.