Azure API应用程序代理生成错误

标签 azure visual-studio-2013 swagger azure-api-apps

我能够在 Azure 中成功创建测试 API 和主机。但是,当我尝试创建代理客户端时,收到以下错误。

[Fatal]Error generating service model: The operation 'Get' has a body parameter, but did not have a supported MIME type ('application/json') in its Consumes property.
Exception: There was an error during code generation when trying to add a client for the Microsoft Azure API App
Generating client code and adding to project failed

我检查了 Swagger 文件,Contains 节点为空。当我将其更改为

"consumes": [ "application/json", "application/xml" ]

代理创建工作正常。为什么自动生成的 Swagger json 没有设置 Contains 属性?创建 API 应用程序时,我使用了默认的 SwaggerConfig。我是否缺少某些配置?任何帮助将不胜感激。

最佳答案

正如我从评论中发现的,解决方案是删除 HttpRequestMessage 作为 Action 的参数。这将使 API 应用程序客户端能够生成代码。

如果您需要模拟该对象,请按照 here 中记录的方式进行操作或另一个例子here .

关于Azure API应用程序代理生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29316677/

相关文章:

python - 如何测试 Connexion/Flask 应用程序?

azure - 从 VPS 迁移到 Azure

azure - HTTP 代理 + WCF netMessagingBinding + 服务总线

visual-studio - 在使用 Visual Studio 创建的项目之外进行 TypeScript 编译

c# - 无法加载文件或程序集 'WebGrease,版本 = 1.5.1.25624

c# - 在Swagger UI中,如何自定义body input ui(model schema UI)

azure - 如何为同一资源类型的多个资源创建不同的指标类型警报

asp.net - Azure 网站 301 重定向 - 我将其放在哪里?

css - 在 Visual Studio 2013 中设置默认 CSS 验证架构?

Swagger 从 1.2 到 2.0 规范的迁移