Blog: NSwag

NSwag Tutorial: Implement a custom operation processor to define ReDoc code samples

November 1, 2017, (updated on November 2, 2017), Software Development

With NSwag you can implement custom operation processors and apply them to ASP.NET Core MVC or Web API controller operations. These processors then get picked up by NSwag and are applied to the given operation in the Swagger specification. This article shows how to implement a custom operation processor using the example of adding code samples to the ReDoc UI. The ReDoc UI processes the x-code-samples property on operations. Here is a sample Swagger specification: { ... "paths": { "/person": { "post": { "summary": "Adds a new person.", "operationId": "addPerson", "x-code-samples": { "lang": "CSharp", "source": "console.log('Hello World');" } ... } […] Read more...

Tags: , , , ,

NSwag Tutorial: Generate an Angular TypeScript client from an existing ASP.NET Web API web assembly

October 1, 2016, (updated on July 6, 2017), 11 comments, Software Development

This tutorial shows how to generate an Angular TypeScript client with the NSwag Swagger toolchain. You can use this client in your Angular 2 SPA (single-page application) to consume the web services of an existing Web API project. The metadata for the client generator will be loaded from an existing .NET assembly which contains your Web API controller classes. The NSwag project provides many other TypeScript templates (for targeting other JS frameworks) and also a C# client generator. Introduction video: For ASP.NET Core projects, I recommend to use the middleware to generate the Swagger spec (there are some problems loading […] Read more...

Tags: , , , , ,

NSwag Tutorial: Integrate the NSwag toolchain into your ASP.NET Web API project

September 30, 2016, (updated on October 1, 2016), Software Development

This tutorial shows how to integrate NSwag (Swagger toolchain for .NET) so that you can access your Web API actions with the Swagger UI and a generated C# client library. The toolchain can be integrated into the following three types of Web API projects: Global.asax-based Web projects (full .NET Framework) OWIN-based Web projects (full .NET Framework) ASP.NET Core based projects (full .NET Framework or .NET Core) For each project, the integration is a little bit different, but this tutorial will provide links to all supported ways. Just follow the steps. 1. Create and setup a new Web API project First […] Read more...

Tags: , , , , , , ,


  Page 1 of 1