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

Azure API App proxy generation error

我能够在 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。我缺少一些配置吗?任何帮助将不胜感激。

正如我从评论中发现的那样,解决方案是删除作为 Action 参数的 HttpRequestMessage。这将使 API App Client 生成代码 OK。

如果您需要模拟对象,请按照here or another example here中记录的方式进行操作。