Hi, I have just merged the latest 4.1 code into my project. It all runs correctly and displays the swagger API in the web browser when the project is run. But when I try execute the nswag refresh.bat I am getting the below error " Sequence contains more than one matching element". Any idea why this might be happening?
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 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:line 18
at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateFile(SwaggerDocument document, ClientGeneratorOutputType type) in C:\Data\Projects\NSwag\src\NSwag.CodeGeneration\ClientGeneratorBase.cs:line 90
at NSwag.Commands.SwaggerToTypeScriptClientCommand.<
Thanks, Matt
6 Answer(s)
-
0
Hi,
Probably there are two methods with same name but with different parameters in one of your app services. Can you check the changed app services for that ?
Thanks.
-
0
Hello Ismail,
I am facing the same problem out of a sudden. I went many times through the swagger to locate any duplicate method names I cannot find.
Is there a way to debug the nswag tool and see where exactly it is breaking?
Thank you Bilal
-
0
@bilalhaidar not that I know. Have you recently upgrade NSWAG ? It can cause such problems sometimes.
-
0
Hello Ismail,
I managed to solve out this issue by changing in the AppService I have. I opened a ticket on the NSWAG forum and the problem has to do with Swaggable generating more than one body parameter for the methods.
<a class="postlink" href="https://github.com/RSuter/NSwag/issues/992">https://github.com/RSuter/NSwag/issues/992</a>
The solution proposed to use one of the offered middlewares by NSWAG instead to generate more compatible json with NSWAG.
Maybe it is something worth checking it out, maybe you would like to update the template to make use of this instead of the swaggable.
Thanks
-
0
Thanks @bilalhaidar,
I have just checked the issue on NSWAG repository. We are not thinking of changing Swahsbuckle in the short term but we will think on this issue.
-
0
Thanks. I just wanted to let you know their feedback.