gpt4 book ai didi

azure - 从 swagger 文件生成 Azure API 应用程序客户端时出现 NotSupportedException

转载 作者:行者123 更新时间:2023-12-01 13:28:29 26 4
gpt4 key购买 nike

我有一个由 Swashbuckle 从我的 Web Api 服务生成的 swagger 元数据文件。当我尝试生成 Azure API 应用程序客户端(使用 Visual Studio 2015 > 添加 > Azure API 应用程序客户端 > Swagger 元数据文件)时,会引发以下错误:

Generating client code and adding to project started
Generate client code for Microsoft Azure API App with following parameters:
Microsoft Azure API App Name: Contoso.Api1, Base namespace: Automation.Http, Metadata file path: C:\Users\contoso\Desktop\swagger_current.json
[Info]AutoRest Core 0.9.7.0
[Info]Initializing code generator.
[Info]Successfully initialized CSharp Code Generator 1.0.5584.22489
[Info]Initializing modeler.
[Info]Successfully initialized Swagger Modeler 1.0.5584.22490
[Info]Parsing swagger json file.
[Info]Generating client model from swagger model.
[Info]Initializing code generator.
[Info]Successfully initialized CSharp Code Generator 1.0.5584.22489
[Fatal]Error generating syntax tree: Failure during generation of method PutItem.
Failure during serialization generation of method PutItem.
System.NotSupportedException: Contoso.Api.Types.ContosoModel - False

System.NotSupportedException: Contoso.Api.Types.ContosoModel - False
at Hyak.SerializationGenerator.CreateSerializationMethod(ISerializationBase serializationFormat)
at Hyak.JsonSerializationGenerator.SerializeJsonRequest[T](StatementsBuilder`1 builder, IJsonBase root)
at Hyak.JsonSerializationFramework.Serialize[T](ISerializationBase serialization, StatementsBuilder`1& builder)
at Hyak.CodeGeneratorExtensions.SerializationExtensions`1.Serialize(IDictionary`2 requestBodyDefinitions, Type& requestType)
at Hyak.ClientGenerator.<>c__DisplayClass3a`1.<SerializeRequest>b__37()
at Hyak.Ensure.ErrorContext(Action action, String context)
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
Adding client for Microsoft Azure API App failed

我想我在我的模型中使用了生成器不支持的东西。我能以某种方式获得更详细的错误消息来解释问题所在吗?

最佳答案

我遇到了同样的问题,我在 SwaggerConfig.cs 中使用/启用了“c.UseFullTypeNameInSchemaIds”,这导致了问题:生成语法树时出错 + 方法生成期间失败 + 方法序列化生成期间失败 + System.NotSupportedException 这样做的结果是定义.json 中的 "items": { "$ref":"生成不正确。

关于azure - 从 swagger 文件生成 Azure API 应用程序客户端时出现 NotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35171439/

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