RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.41k stars 536 forks source link

NSwagStudio Exception while creating API Allegro.pl #1030

Open frankii91 opened 5 years ago

frankii91 commented 5 years ago

I am "thin" in these blocks and prose for help because there is some mistake ...

file https://developer.allegro.pl/swagger.yaml

It gives mistakes as below

NSwagStudio v13.0.4.0 " System.InvalidOperationException: Error while rendering Liquid template CSharp/Class: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Sequence contains more than one matching element

Runtime: NetCore21 at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) at NJsonSchema.CodeGeneration.Models.ClassTemplateModelBase.DerivedClassModel..ctor(String typeName, JsonSchema schema, OpenApiDiscriminator discriminator, TypeResolverBase resolver) at NJsonSchema.CodeGeneration.Models.ClassTemplateModelBase.b13_0(KeyValuePair2 p) at System.Linq.Enumerable.SelectEnumerableIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) --- End of inner exception stack trace --- at DotLiquid.Context.HandleError(Exception ex) at DotLiquid.Block.RenderAll(List1 list, Context context, TextWriter result) at DotLiquid.Document.Render(Context context, TextWriter result) at DotLiquid.Template.RenderInternal(TextWriter result, RenderParameters parameters) at DotLiquid.Template.Render(TextWriter writer, RenderParameters parameters) at DotLiquid.Template.Render(RenderParameters parameters) at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Sequence contains more than one matching element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate) at NJsonSchema.CodeGeneration.Models.ClassTemplateModelBase.DerivedClassModel..ctor(String typeName, JsonSchema schema, OpenApiDiscriminator discriminator, TypeResolverBase resolver) at NJsonSchema.CodeGeneration.Models.ClassTemplateModelBase.b13_0(KeyValuePair2 p) at System.Linq.Enumerable.SelectEnumerableIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) --- End of inner exception stack trace --- at DotLiquid.Context.HandleError(Exception ex) at DotLiquid.Block.RenderAll(List1 list, Context context, TextWriter result) at DotLiquid.Document.Render(Context context, TextWriter result) at DotLiquid.Template.RenderInternal(TextWriter result, RenderParameters parameters) at DotLiquid.Template.Render(TextWriter writer, RenderParameters parameters) at DotLiquid.Template.Render(RenderParameters parameters) at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() --- End of inner exception stack trace --- at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() 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) in C:\projects\nswag\src\NSwag.CodeGeneration\ClientGeneratorBase.cs:line 75 at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.b__83_0() in C:\projects\nswag\src\NSwag.Commands\Commands\CodeGeneration\OpenApiToCSharpClientCommand.cs:line 242 at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.RunAsync() in C:\projects\nswag\src\NSwag.Commands\Commands\CodeGeneration\OpenApiToCSharpClientCommand.cs:line 228 at NSwag.Commands.CodeGeneration.SwaggerToCSharpClientCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\CodeGeneration\OpenApiToCSharpClientCommand.cs:line 217 at NSwag.Commands.NSwagDocument.ExecuteAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocument.cs:line 85 at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 85 at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 32 at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) at NConsole.CommandLineProcessor.Process(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 56 "

RicoSuter commented 5 years ago

Looks like a special case with oneOf/allOf/inheritance...

RicoSuter commented 5 years ago

Moved to NJsonSchema - we need to repro this directly in NJS with a unit test.