如何在Visual Studio 2017中更新AutoRest [英] How to update AutoRest in visual studio 2017

查看:86
本文介绍了如何在Visual Studio 2017中更新AutoRest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文我想通过在Visual Studio 2017中使用添加"/"REST API客户端..."将AutoRest生成的客户端用于webapi服务.但是,它给出以下错误:

  • [Info] AutoRest Core 0.16.0.0
  • ...
  • [致命]生成客户端模型时出错:不支持集合格式"multi" (在参数"xxx"中).

较旧版本的AutoRest(例如0.16.0)不支持多"收集格式.因此,我安装了最新版本的AutoRest 0.17.3.使用Nuget.但是,当我使用添加"/"REST API客户端..."时,它仍然使用0.16.0版本的AutoRest并给我同样的错误.似乎Visual Studio 2017具有内置的AutoRest版本0.16程序集.

问题如何获取最新版本的AutoRest并将其集成到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?

解决方案

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

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

这篇关于如何在Visual Studio 2017中更新AutoRest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆