使用Swagger定义生成c#客户端

时间:2018-03-27 23:17:20

标签: c# visual-studio rest api swagger

我试图使用Swagger示例Petstore定义.json文件 - https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore.json

我使用VS 2017>添加>添加REST Api客户端功能。导入成功,Swagger Petstore代理类已成功生成并添加到我的项目中。

enter image description here

现在我想编写实际上可以调用Petstore API的C#代码。我无法找到任何利用代理类的具体示例。

我使用REST服务的方式一直在使用C#中的Web Client类 -

string sendText = "abc";
WebClient client = new WebClient();
c.Headers[HttpRequestHeader.ContentType] = "text/xml";
result = c.UploadString(url, sendText);

如何在Pet Store API上编写调用PUT GET POST等操作的代码?

0 个答案:

没有答案
相关问题