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/

相关文章:

Azure 机器学习工作室 : How to import images dataset?

azure - 我可以通过编程方式为 Azure 服务主体创建新密码吗?

c# - Newtonsoft 11.0.0.0 无法在 Azure Function App 2.0 上加载

visual-studio - 如何获取缓存在注册表中的 Visual Studio Online 凭据?

visual-studio-2013 - nuget 网站的 DNS 问题导致全局 NuGet 包恢复失败

dictionary - Swagger:<字符串,对象> 的映射

Azure 移动服务 Facebook 登录无需用户名/密码

visual-studio - Resharper - 如何导入所有缺失的命名空间?

c# - Servicestack 对象参数未通过 Swagger-UI 传递给服务

api - Swagger 错误 |数据与 'oneOf' 中的任何架构都不匹配