Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
143 stars 165 forks source link

Exception: The method or operation is not implemented. #3292

Open cilerler opened 1 year ago

cilerler commented 1 year ago

I encountered an internal error while using AutoRest.CSharp with the following command:

autorest --input-file=".\3.0.0.json" --csharp --generation1-convenience-client --v3

Here is the file 3.0.0.json
I have appended .txt to the file in order to attach them to this issue.

fatal   | Internal error in AutoRest.CSharp
   Please file an issue at https://github.com/Azure/autorest.csharp/issues/new.
   Attach the written 'Configuration.json' and 'CodeModel.yaml' or the original swagger so we can reproduce your error.

Exception: 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 281
   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 208
   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 112
   at AutoRest.CSharp.Output.Models.DataPlaneRestClient.EnsureNormalMethods() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\DataPlane\Output\DataPlaneRestClient.cs:line 35
   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 51
   at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](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 26
   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 34
   at AutoRest.CSharp.AutoRest.Plugins.DataPlaneTarget.Execute(GeneratedCodeWorkspace project, CodeModel codeModel, SourceInputModel sourceInputModel) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\DataPlane\AutoRest\DataPlaneTarget.cs:line 53
   at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.ExecuteAsync(Task`1 codeModelTask) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\AutoRest\Plugins\CSharpGen.cs:line 32
   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 96
fatal   | Process() cancelled due to failure
error   |   Error: Plugin csharpgen reported failure.
error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.
ArcturusZhang commented 1 year ago

Hi @cilerler thanks for this issue! From the json file you attached, you are using OpenAPI 3.0, but our generator does not officially support openAPI 3.0 yet. Could you try to convert your swagger to 2.0 and try again?

cilerler commented 1 year ago

I appreciate your prompt response. Do you know when the generator will officially support OpenAPI 3.0? I tried using the API spec converter (https://lucybot-inc.github.io/api-spec-converter/) to convert the OpenAPI 3.0 specification to Swagger 2.0, but I haven't had any luck with it. Is there any other workaround or solution you would recommend?

josefree commented 1 year ago

May I know what's the specific reason you choose to use OA3? We do not have a plan to support OA3. We are investing TypeSpec as the replacement of OA2 in Azure API definition. Refer to https://aka.ms/TypeSpec/azuredoc. Currently, TypeSpec can generate OA2, and then supported by AutoRest.

cilerler commented 1 year ago

@josefree I didn't make the choice to use OA3; it was a decision made by the third party whose API I'm interacting with. I simply retrieved their OA3 file so that I could generate a client for my own use.