gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:15:10 25 4
gpt4 key购买 nike

我能够在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com