Thursday 10 January 2019

Automate C# Client API for Web API DotNetCore

If you have developed Web API in any platform like .Net Core and you have corresponding swagger json documentation then developing client to consume that service is just waste of time. Will recommend to have look on NSwagStudio of Nswag [Official Microsoft documentation].

Follow simple steps: 

1. Implement Swashbuckle or NSwag in your application and get swagger specification like: https://localhost:44359/swagger/v1.0/swagger.json which contains JSON Data.
2. Get MSI installer of NSwagStudio from and install it in your client machine.

3. Open NSwagStudio, put swagger specification url, create local copy explore some setting and get your client in few clicks

5. You can save your code in any existing project. by changing some settings

Set appropriate name for namespace

 Specify Output file path

Click on Generate Files and you will get file like this, build it and use it anywhere.