How to update AutoRest in visual studio 2017
Asked Answered
A

1

6

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?

Anderson answered 24/4, 2017 at 18:27 Comment(1)
Seems this question was also asked on GitHub, See it here: github.com/Azure/autorest/issues/2198Cravat
L
1

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

Leah answered 2/6, 2019 at 7:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.