我正在尝试使用 openapi 规范 yaml 生成 C# 模型和客户端
如果我在 multipart/form-data 中有一个枚举类型的属性,如下所示:
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
Precedence:
type: string
enum:
- PRIMARY
- SECONDARY
- COMMON
它抛出错误:
fatal | System.NotImplementedException: The method or operation is not implemented.
at AutoRest.CSharp.Output.Models.RestClientBuilder.BuildRequestBody(IReadOnlyCollection`1 allParameters, BodyMediaType bodyMediaType, OutputLibrary library) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClientBuilder.cs:line 285
at AutoRest.CSharp.Output.Models.RestClientBuilder.BuildRequest(InputOperation operation, IReadOnlyCollection`1 requestParts, Parameter bodyParameter, OutputLibrary library) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClientBuilder.cs:line 212
at AutoRest.CSharp.Output.Models.RestClientBuilder.BuildMethod(InputOperation operation, DataPlaneResponseHeaderGroupType responseHeaderModel) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClientBuilder.cs:line 113
at AutoRest.CSharp.Output.Models.DataPlaneRestClient.EnsureNormalMethods() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\DataPlane\Output\DataPlaneRestClient.cs:line 44
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at AutoRest.CSharp.Output.Models.RestClient.GetOperationMethod(InputOperation request) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClient.cs:line 107
at AutoRest.CSharp.Output.Models.RestClient.BuildAllMethods()+MoveNext() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClient.cs:line 45
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
at AutoRest.CSharp.Output.Models.RestClient.getMethods() in D:\a\work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Models\RestClient.cs:line 24
at AutoRest.CSharp.Generation.Writers.RestClientWriter.WriteClient(CodeWriter writer, DataPlaneRestClient restClient) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Generation\Writers\RestClientWriter.cs:line 32
at AutoRest.CSharp.AutoRest.Plugins.DataPlaneTarget.Execute(GeneratedCodeWorkspace project, CodeModel codeModel, SourceInputModel sourceInputModel, SchemaUsageProvider schemaUsageProvider) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\DataPlane\AutoRest\DataPlaneTarget.cs:line 55
at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.ExecuteAsync(CodeModel codeModel) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\CSharpGen.cs:line 38
at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.Execute(IPluginCommunication autoRest) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\CSharpGen.cs:line 128
at AutoRest.CSharp.AutoRest.Plugins.PluginProcessor.Start(IPluginCommunication autoRest) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\PluginProcessor.cs:line 39
fatal | Process() cancelled due to failure
如果我删除枚举,它就会成功执行,
命令:autorest --input-file=swagger.yaml --csharp -- Generation1-convenience-client
您的
enum
关键字缩进无效。应与 type
关键字内联。
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
Precedence:
type: string
enum:
- PRIMARY
- SECONDARY
- COMMON