Error generating code for AppCenter API (System.InvalidOperationException: The properties 'id', 'name' are defined multiple times.)
See original GitHub issueAm trying to generate a C# rest client for the Visual Studio AppCenter API (the API itself can be browsed at: https://openapi.appcenter.ms/#/) as there’s no official C#/.NET client.
Command line (this is called in Visual Studio when the build command is invoked):
C:\Users\buildrunner\.nuget\packages\nswag.msbuild\13.0.5\build\../tools/Win/NSwag.exe openapi2csclient /className:AppCenterRestApi /namespace:AppCenterApi /input:C:\Users\buildrunner\source\repos\AppCenterRestClient\swagger.json /output:C:\Users\buildrunner\source\repos\AppCenterRestClient\obj\swaggerClient.cs
JSON input file is from https://openapi.appcenter.ms/#/, or viewed directly via https://api.appcenter.ms/preview/swagger.json
Stack trace:
System.InvalidOperationException: The properties 'id', 'name' are defined multiple times.
at NJsonSchema.JsonSchema.get_ActualProperties()
at NJsonSchema.CodeGeneration.CSharp.Models.ClassTemplateModel..ctor(String typeName, CSharpGeneratorSettings settings, CSharpTypeResolver resolver, JsonSchema schema, Object rootObject)
at NJsonSchema.CodeGeneration.CSharp.CSharpGenerator.GenerateClass(JsonSchema schema, String typeName)
at NJsonSchema.CodeGeneration.GeneratorBase.GenerateTypes()
at NJsonSchema.CodeGeneration.CSharp.CSharpGenerator.GenerateTypes()
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(ClientGeneratorOutputType outputType)
at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.<<RunAsync>b__83_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.<RunAsync>d__83.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.<RunAsync>d__82.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.<ProcessSingleAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at NConsole.CommandLineProcessor.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.Process(String[] args)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
The method 'get' on path '/Site' is registered multiple times - ...
System.InvalidOperationException: The method 'get' on path '/Site' is registered multiple times. at NSwag.Generation.AspNetCore.
Read more >Unable to compile Xamarin.Android project in VS 2022 ...
targets(106,5): error XAPRAS7009: System.InvalidOperationException: PE image does not have metadata. 1>C:\Program Files\dotnet\packs\Microsoft.
Read more >Sitecore Experience Platform 8.0
This topic contains a glossary of Sitecore Experience Analytics terms, with short definitions. Asset. A piece of content, for example, a PDF file,...
Read more >Monitoring Application Performance with Application Insights
Application Insights is an extensible Application Performance Management (APM) service for web developers on multiple platforms.
Read more >Build a Sample Application with Microservices
In this lab we will go through a set of steps for building a sample application with multiple microservices. DevOps MPP Course Source....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK but my input is a JSON schema, as I’m trying to generate C# code for the REST client. The command I’m trying to run is
NSwag.exe openapi2csclient /className:AppCenterRestApi /namespace:AppCenterApi /input:C:\Users\mamift\source\repos\AppCenterRestClient\swagger.json /output:C:\Users\mamift\source\repos\AppCenterRestClient\swaggerClient.cs
Is there any interface in the command line that can be used to pass that flag to flatten the classes? When I go
NSwag.exe help openapi2csclient
I cannot find a flag that refers to class flattening.I’m having a similar issue trying to make a client using the dotnet-openapi tool, it complains about “fireRate” existing multiple times. Though loading the spec using the swagger editor I find no issues with the file.
OpenApi spec Url: https://docs.warframestat.us/openapi.json