3
我的Web Api服務中有Swashbuckle生成的Swagger元數據文件。當我嘗試生成Azure的API應用程序客戶端(使用Visual Studio 2015年>添加> Azure的API應用程序客戶端>揚鞭元數據文件,下面的錯誤被拋出:從Swagger文件生成Azure API應用程序客戶端時出現NotSupportedException
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獲得更詳細的錯誤消息,說明了什麼問題?
我假設你已經檢查過你的Swagger在http://editor.swagger.io/中工作嗎? – Charlie
另一個選擇是使用[Swagger Codegen](https://github.com/swagger-api/swagger-codegen)(免費和開源)與您的C#API客戶端(或ASP.net中的服務器存根)生成C#API客戶端招搖規範。 –
你是否找到了你的問題的答案?我遇到了同樣的問題。 editor.swagger.io不會給我任何錯誤。 –