Q: What are the rules to use nswag to avoid exceptions
See original GitHub issueHello, I have been using nswag from the command line for some time now. Today, out of a sudden, I started getting this error:
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at NSwag.CodeGeneration.TypeScript.Templates.RequestBodyTemplate.TransformText() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\RequestBodyTemplate.tt:line 2
at NSwag.CodeGeneration.TypeScript.Templates.AngularClientTemplate.TransformText() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt:line
50
at NSwag.CodeGeneration.TypeScript.Templates.AngularClientTemplate.Render() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.Extensions.cs:l
ine 18
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(SwaggerDocument document, ClientGeneratorOutputType type) in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\ClientGeneratorBa
se.cs:line 90
at NSwag.Commands.SwaggerToTypeScriptClientCommand.<<RunAsync>b__100_0>d.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 265
--- 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.SwaggerToTypeScriptClientCommand.<RunAsync>d__100.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 256
--- 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.SwaggerToTypeScriptClientCommand.<RunAsync>d__99.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 249
--- 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.NSwagDocumentBase.<ExecuteAsync>d__28.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\NSwagDocumentBase.cs:line 187
--- 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.Document.ExecuteDocumentCommandBase.<ExecuteDocumentAsync>d__5.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:
line 52
--- 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.Document.ExecuteDocumentCommandBase.<RunAsync>d__4.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:line 39
--- 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() in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 139
--- 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.<ProcessAsync>d__11.MoveNext() in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 107
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\Data\Projects\NSwag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 59
---> (Inner Exception #0) System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at NSwag.CodeGeneration.TypeScript.Templates.RequestBodyTemplate.TransformText() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\RequestBodyTemplate.tt:line 2
at NSwag.CodeGeneration.TypeScript.Templates.AngularClientTemplate.TransformText() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.tt:line
50
at NSwag.CodeGeneration.TypeScript.Templates.AngularClientTemplate.Render() in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration.TypeScript\Templates\AngularClientTemplate.Extensions.cs:l
ine 18
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(SwaggerDocument document, ClientGeneratorOutputType type) in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\ClientGeneratorBa
se.cs:line 90
at NSwag.Commands.SwaggerToTypeScriptClientCommand.<<RunAsync>b__100_0>d.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 265
--- 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.SwaggerToTypeScriptClientCommand.<RunAsync>d__100.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 256
--- 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.SwaggerToTypeScriptClientCommand.<RunAsync>d__99.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\SwaggerToTypeScriptClientCommand.cs:line 249
--- 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.NSwagDocumentBase.<ExecuteAsync>d__28.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\NSwagDocumentBase.cs:line 187
--- 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.Document.ExecuteDocumentCommandBase.<ExecuteDocumentAsync>d__5.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:
line 52
--- 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.Document.ExecuteDocumentCommandBase.<RunAsync>d__4.MoveNext() in C:\Data\Projects\NSwag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommandBase.cs:line 39
--- 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() in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 139
--- 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.<ProcessAsync>d__11.MoveNext() in C:\projects\nconsole\src\NConsole\CommandLineProcessor.cs:line 107<---
child_process.js:524
throw err;
^
Error: Command failed: "D:\Workspace\...\node_modules\nswag\bin/binaries/full/nswag.exe" run
at checkExecSyncError (child_process.js:481:13)
at Object.execSync (child_process.js:521:13)
at Object.<anonymous> (D:\Workspace\...\node_modules\nswag\bin\nswag.js:27:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
I looked thoroughly in my code and I cannot find any duplicate method names in my controllers.
Is there another reason for such an exception to happen? What if 2 different method names but with the same input type, does that cause any problem?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Q: What are the rules to use nswag to avoid exceptions #992
Hello, I have been using nswag from the command line for some time now. Today, out of a sudden, I started getting this...
Read more >Is it a best practice to use NSwag generated code for calls ...
I'm currently working with this for the first time and in a .Net to .Net senario NSwag is not generating the full validation...
Read more >Get started with NSwag and ASP.NET Core
Learn how to use NSwag to generate documentation and help pages for an ASP.NET Core web API.
Read more >Maintaining API Clients With NSwag Model Generation
In summary, NSwag code generation is a valuable tool for maintaining API clients. It enabled easier management of change and promoted a better ......
Read more >Exception when multiple OpenAPI services refrences is ...
I try to use the service reference OpenAPI in Visual Studio 2019, to generate clients based on existing swagger endpoints.
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
Closed because it is a problem with Swashbuckle.
Thanks a lot. I will give it a try.