Tuesday, May 28, 2019

Generating a REST API Client from Visual Studio 2017 and 2019

For the past year or so, I have been doing a lot of development that involves producing an OpenAPI specification document from a .NET Core based REST API and generating client code using things like AutoRest, Swagger Codegen, OpenAPI Codegen, and NSwag. My problem with these tools is that I often need to leave Visual Studio and quite often update the tool before I can re-generate my REST API client code. After doing this a couple of times I thought that I should just build a Visual Studio extension to make my life easier. At the end of last year I started work on a Visual Studio extension called the REST API Client Code Generator, A collection of Visual Studio custom tools for generating a strongly typed REST API Client from an Open API / Swagger specification file

With this tool I can easily switch from NSwag, AutoRest, Swagger Codegen, and OpenAPI Codegen, and re-generate my code by making changes directly to the OpenAPI specification document I have in my project.



I built Visual Studio Custom Tools for each code generator so every time I make changes to the OpenAPI specification document in my project, the client code gets automatically re-generated.






You can include an NSwag Studio file in the project and right click and re-generate my client code


And a feature that I just built today, adding a dialog for adding a new OpenAPI specification document file.




This project is open source and you get browse the repository on here and download the VSIX file from the Visual Studio Marketplace