Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update AutoRest in visual studio 2017

Context I would like to use AutoRest generated client for a webapi service by using "Add"/"REST API Client..." in visual studio 2017. However, it gives the following error:

  • [Info]AutoRest Core 0.16.0.0
  • ...
  • [Fatal]Error generating client model: Collection format "multi" is not supported (in parameter 'xxx').

The older version of AutoRest (e.g. 0.16.0) does not support "multi" collection format. So I installed the latest version AutoRest 0.17.3. using Nuget. But when I use "Add"/"REST API Client...", it still uses 0.16.0 version AutoRest and gives me the same error. It seems visual studio 2017 has a built-in AutoRest version 0.16 assembly.

Question How do I get the latest version of AutoRest and integrate it in Visual studio 2017?

like image 419
ld dl Avatar asked Apr 24 '17 18:04

ld dl


1 Answers

I also had this problem so I built a tool for it called REST API Client Code Generator. I worked in teams where we used tools like AutoRest, NSwag, and Swagger Codegen to generate our REST API Clients and 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

enter image description here

The REST API Client Code Generator piggy backs on top of AutoRest, NSwag, and the Java SDK for Swagger Codegen CLI and OpenAPI Codegen CLI. So to be able to use AutoRest you will need Node.js to be installed and then you need to manually install AutoRest using NPM

npm install -g autorest

Using the tool will add the Swagger.json file to the C# project and set a custom tool to it so every time the changes are made to the Swagger.json file, the API Client code is re-generated. You will have to manually update the Swagger.json file though if you use Auto, NSwag, Swagger Codegen, OpenAPI Codegen though. But if you chose to use NSwag Studio to generate code then you can just re-generate the code directly from the .nswag file from the C# project

enter image description here

like image 183
Christian Resma Helle Avatar answered Oct 26 '22 01:10

Christian Resma Helle