"REST API Client" option in Visual Studio for ASP.NET Core projects?

Viewed 19962

I've got a ASP.NET REST API up and running in Azure. From an older .NET 4.5 project in Visual I've generated a client using this menu option:

Old .NET 4.5 project

But when I create a new ASP.NET Core (ASP.NET 5) project, and want to generate the client there is no such option:

New ASP.NET Core project

What is the intended way to generate the client for my REST api in ASP.NET Core projects?

2 Answers

I also had this problem so I built a tool called REST API Client Code Generator to solve it. I worked in teams where we used tools like AutoRest, NSwag, and Swagger Codegen to generate our REST API Clients and consume it from .NET Core web applications. It always annoyed me that the "Add New - REST API Client..." tooling in Visual Studio didn't always work and was very troublesome when it was time to re-generate the client

Add New REST API Client

Add New REST API Client Dialog

This would add the OpenAPI specification file (Swagger.json) to the project and set a custom tool so that every time changes are made to it the REST API Client code is re-generated. You can also right click on the Swagger.json file and switch code generators

Re-generate or Switch Code Generator

And for NSwag Studio files you can also just right click and re-generate

Generate NSwag Studio Output

I built the tool mainly for personal use and for use within my teams but if you find it useful and think it lacks something you really need then please reach out

Related