从swagger文件

时间:2016-02-03 08:00:10

标签: azure swagger azure-api-apps swashbuckle

我的Web Api服务中有Swashbuckle生成的swagger元数据文件。当我尝试生成Azure API App Client时(使用Visual Studio 2015>添加> Azure API App Client> 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

我想我在我的模型中使用了生成器不支持的东西。 我可以以某种方式得到更详细的错误消息,解释什么是错的吗?

1 个答案:

答案 0 :(得分:0)

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