Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

NSwag Refresh error, more than one match #3450


User avatar
0
ribbo created

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, Func2 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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    bilalhaidar created

    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

  • User Avatar
    0
    ismcagdas created
    Support Team

    @bilalhaidar not that I know. Have you recently upgrade NSWAG ? It can cause such problems sometimes.

  • User Avatar
    0
    bilalhaidar created

    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

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    bilalhaidar created

    Thanks. I just wanted to let you know their feedback.